all groups > flash actionscript > january 2005 >
You're in the

flash actionscript

group:

Using a variable as part of a movie name


Re: Using a variable as part of a movie name Byron Canfield
1/16/2005 12:29:04 PM
flash actionscript:
[quoted text, click to view]
Note, however, that if you have the first child clip with a distinct name,
the child clips of that need not be distinct from those in other clips, that
is, "button2_mc.buttonScale_mc" is a distinct entity from
"button3_mc.buttonScale_mc" -- the latter part, "buttonScale_mc" need not
have a different number, and including one merely makes your structure all
that much more unnecessarily complex to code.


--
--------
Reality will not be altered to comply with preconceived notions.

Byron "Barn" Canfield

Using a variable as part of a movie name George Webb
1/16/2005 3:47:53 PM
buttonNumber = 2;

_root.mainMenu_mc.button2_mc.button2Scale_mc.button2Text.autoSize = true;

For the above line of code please could someone tell me how to replace the
number "2" with the variable "buttonNumber.
Thanks.
Re: Using a variable as part of a movie name derobinson
1/16/2005 5:14:14 PM
Something like this:

_root.mainMenu_mc["button" + buttonNumber + "_mc"]["button" + buttonNumber +
"Scale_mc"]["button" + buttonNumber + "Text"].autoSize = true;

The brackets tell Flash to evaluate what's in between. You're putting in a
combination of strings and variables, so be careful of the quotation marks.
Also, when you use square brackets, there is an assumption that there is a dot
(".") before the bracket, so you always have to specify a scope when using them.

Good luck!

AddThis Social Bookmark Button