Not a number, yes a bug

Published April 12, 2005
Advertisement
One thing that had bugged me for a while is that Duck Tiles wouldn't compile as a Flash Player 7 app.

Lemme back up. One thing you can do with Flash is compile your app to be compliant with previous versions of the player. For some reason I can't recall, Duck Tiles had always been compiled for Flash 6 player. A couple of weeks ago, I noticed this and recompiled the game for Flash 7, but it'd lock up as soon as you tried to play a level.

Turns out the problem is with earlier Flash handling of NaN (Not a Number). For example, setting something equal to a numeric value that's not defined will give you a NaN. Now then, in previous versions of Flash, adding something to a NaN will set the NaN to that number. . .

var Y = undefined;
var X = Y+1; // X is now a NaN
X++; // X is now 1

Unfortunately, this violates the ECMAScript spec, so it was fixed with the newest ActionScript in Flash 7. Now adding something to a NaN doesn't change its value.

var Y = undefined;
var X = Y+1; // X is now a NaN
X++; // X remains a NaN

Turns out I had a loop-counter in my code that was occasionally being set to NaN. It was a bug, but it was a bug I didn't notice in the old Flash 6 version, because the loop counter would get incremented and would eventually finish. When compiled for Flash 7, though, the counter would remain NaN after being incremented.

Thus I had an infinite loop which would eventually take down the player.
Previous Entry Ooooooh
Next Entry Zow
0 likes 2 comments

Comments

Stompy9999
It's always the little things...
April 12, 2005 08:49 PM
MauMan
Although it may not apply to this case, this is one of the reasons why I like multi-platform development. Each vendor's compiler is tuned to find certain bugs. After getting code to build and run on 3-4 platforms/compiler you've really linted the code well and tend to find problems like these.
April 13, 2005 08:18 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement