Skip to main content
October 18, 2006
Answered

Changing text inside a button

  • October 18, 2006
  • 2 replies
  • 298 views
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 ;
}
But it doesn't work... can anybody tell me what am doing wrong?
This topic has been closed for replies.
Correct answer kglad
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.

2 replies

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
October 19, 2006
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.
kglad
Community Expert
Community Expert
October 18, 2006
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.
October 18, 2006
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 ;
Y += 20;
}