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

flash actionscript : dynamic button text


amiller
12/31/2004 5:25:44 PM
Hello all- Here comes a newbie question. How do I create a button that has a
dynamic label? I've created a button, put a dynamic text field on top and gave
it a name of 'label'. Then in frame one I have an instance of the button
(button1) and in my actions code I have button1.label.text = 'Who We Are';
What am I doing wrong here ? I simply want to supply the text that goes in the
'label' dynamic text field that resides within an instance of button1. TIA,
Aaron
kglad
12/31/2004 5:38:29 PM
amiller
12/31/2004 7:33:13 PM
Thanks for the help, unfortunately I'm still a little confused. I tried using
a movie clip as well, but I'm still missing something. Basically what I want
to do is create 1 button symbol with a dynamic text field on it that will act
as the label, named 'label'. Then I would like to be able to drag multiple
instances of the button symbol onto the stage and dynamically populated the
text field with actionscript for each one with a different label. Problem is
that the text field is going to be named 'label' for each instance of the
button symbol, so how do I specify which button instances text field gets the
data ? That is why I had button1.label.text, because button1 was the instance
name of the button, label being the dynamic textfield, and then text being the
property of the label textfield. I apologize if this is redundant or
completely off base, my knowledge is in CF and I try to play with flash
whenever I get the chance, but my less than stellar graphic abilities usually
deters me:)
kglad
12/31/2004 10:54:11 PM
yes, if you use a movieclip button you should have no problem. your textfield
will always have an instance name of label and that's not a problem:
btn1.label is a different textfield from btn2.label. so, if you have a
movieclip with instance name btn1 on the _root timeline and you have a
textfield with instance name label on btn1's timeline you should be able to use:

btn1.label.text="this is btn1";

if the above doesn't work for you, make sure your instance names are correct
(no typos) and make sure your textfield has a text color different from the
background color.
AddThis Social Bookmark Button