all groups > flash actionscript > october 2006 >
You're in the

flash actionscript

group:

Changing text inside a button


Changing text inside a button jmarchan
10/18/2006 7:30:11 PM
flash actionscript:
I made a button with a dynamic text field inside it and i'm trying to make the
text change at runtime, someting like:

for (i=0; i< myCount; i++) {
duplicateMovieClip(item, "myButton"+i, this.getNextHighestDepth());
this["myButton"+i].myDynamicText.text = Description[i];
}
But it doesn't work... can anybody tell me what am doing wrong?

Re: Changing text inside a button kglad
10/18/2006 10:40:50 PM
is item defined? if so, (and it's the instance name of a movieclip) you would
only expect to see the last duplicate because they are all stacked on one
another. to remedy, give them different _x and/or _y properties.
Re: Changing text inside a button jmarchan
10/18/2006 11:40:34 PM
I omitted part of the code but here it is exactly what i'm doing. What I find
odd is that I can see the buttons lined up, so i can access the _y property
just fine. inside the button there's a dynamic text field named myDynamicText
but i can't change it. any suggestions?

for (i=0; i< myCount; i++) {
duplicateMovieClip(item, "myButton"+i, this.getNextHighestDepth());
this["myButton"+i]._y = Y;
this["myButton"+i].myDynamicText.text = Description[i];
Y += 20;
}
Re: Changing text inside a button kglad
10/19/2006 1:00:28 AM
if your button is a true (non-movieclip) button, then flash won't use the
instance name of a textfield that you place on that button's timeline. flash
assigns the textfield an instance name (something like instance43).

to remedy, use a movieclip button. or use the trace() function to find the
textfield's name assigned by flash and use that.
AddThis Social Bookmark Button