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

flash actionscript : Variable Names Question


Kree8R
6/5/2004 6:25:06 PM
Can FlashMX use numeric only variable names?

Example code:
[quoted text, click to view]

Generates the following error:

**Error** Scene=Scene 1, layer=Preloader Actions, frame=203:Line 1: Syntax
error.
_root.userinfo.data.6_1_11 = 1;

But is fine when I add an alphabetic character to "6_1_11" (such as
"m6_1_11")

I am working on changes for a small portion of a much larger project and if
their new naming system causes errors for this reason, then I will need to
inform someone ASAP.

Thanking you all in advance :-)

Kree8R
6/5/2004 8:40:03 PM
I think I just found the answer:

Colin Moock's book "ActionScript for Flash" - page 39 at bottom:

Legal Variable Names:
- Must start with a letter, an underscore (e.g., _someVar), or a dollar sign
(e.g., $someVar)

rtfm ;-)


[quoted text, click to view]

kglad
6/6/2004 2:27:06 AM
Kree8R
6/6/2004 12:06:15 PM
Thank you :-)

[quoted text, click to view]

Jeckyl
6/6/2004 4:34:05 PM
Note: you can actually have variable whose names starting with a number ..
but you cannot access them directly as a variable. That is because although
the scripting language does not allow variable that start with numbers etc,
the object model underneath lets you name properties with whatever string
you like. That is basically how arrays work .. the properties of the array
are named by numeric names.

This is how you would do it (in your case)

_root.userinfo.data["6_1_11"] = 1;

AddThis Social Bookmark Button