|tips | examples | case studies | downloads | educators | contact | home|
With ActionScript 1.0, we could just start using variables on the fly, without formally declaring them. ActionScript 2.0 is more fussy.
So if you are using some ActionScript from this book (or from any number of nice online tutorials from other people as well), and you're getting some crazy error message, the first thing to try is this:
A different change in your FLA that may solve your problem just as well (especially if the script is pretty simple):
Say you are using a variable named n. The first time you use n in the movie, it's just n. Maybe it's n++ ... maybe it's n = "Mary" or n = 27.
But nowhere in the movie was n ever declared -- with the word var in front of it.
If that's the case for you, then on frame 1 in the Timeline
(not on your button!
You cannot declare a variable on a button), type this ActionScript:
var n = 0;
And by the way -- NaN means "not a number." So when your error message says NaN, this variable business is probably at the root of your trouble.