Jump to content
  • Advertisement
  • entries
    1212
  • comments
    1738
  • views
    1144371

Not a number, yes a bug

Sign in to follow this  
johnhattan

66 views

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.
Sign in to follow this  


2 Comments


Recommended Comments

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.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!