Groups | Blog | Home
all groups > flash actionscript > february 2004 >

flash actionscript : Declaring a Variable



Ibis Fernandez // flashfilmmaker.com
2/15/2004 3:22:12 PM
well I'm provably not advanced enough to know what purposes the colon has in
your script but my guess would be that in your declaration
you are declaring a variable named "my_totalquestions:Number" AND NOT "
my_totalquestions" which what it seems you are trying to trace. Therefore
its only reasonable that it would come out as undefined...

perhaps if you tried trace(my_totalquestions:Number); you might get the
results you are looking for.

Although if you are trying to make "Number" a property of the variable in
question you might want to format it as follows:

//--- Number of Questions--
my_totalquestions.number = 20;
trace(my_totalquestions.number);

this makes you var into a single object which can have many propperties, for
example:
my_totalquestions.number = 20;
my_totalquestions.font = "verdana";
my_totalquestions.style = "bold";
my_totalquestions.fontsize = 10;

trace(my_totalquestions.number);

-Ibis




[quoted text, click to view]

CSEd2
2/15/2004 7:49:43 PM
When I "test movie" a long Flash movie whose first three lines are

//--- Number of Questions--
var my_totalquestions:Number = 20
trace(my_totalquestions)

The output window displays "undefined".

But, If I copy these lines and paste them into a new .fla file and do "test
movie" the output window displays "20". Does anyone know what is going on here
and how it might be corrected

abeall
2/15/2004 9:44:24 PM
CSEd2
2/15/2004 9:57:10 PM
IAMPsycho
2/15/2004 10:31:12 PM
var my_totalquestions = 20

Declaring the variable like that tells flash that my_totalquestions is a
variable set to a numeric value of 20. If you need it to be a string you can
convert by using the My_totalquestions.toString()
AddThis Social Bookmark Button