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

flash actionscript : Button Symbol defined as instance1


BobK101060
5/24/2004 8:21:06 PM
I have dragged a text tool onto an empty stage. I gave it an instance name of
myLabel. I proceeded to create a button symbol of this object. I openned a new
Flash document and dragged the symbol onto the stage. I gave this object an
instance name of myLabelSymbol. When I am in test mode and I look at the object
definitions I see the instance of my symbol defined as
_level0.myLabelSymbol.instance1. I was expecting myLabel to be in place of
instance1 (_level0.myLabelSymbol.myLabel). Can anyone explain to me what I am
doing wrong?

Thank you in advance for your help.
kglad
5/25/2004 1:44:34 AM
BobK101060
5/25/2004 11:23:56 AM
kglad
5/25/2004 2:51:36 PM
you won't be able to reference your textfield because it's not on true
timeline. the button timeline just looks like a timeline for authoring
convenience.

to remedy create a dynamic textfield and convert it into a movieclip. give
the textfield an instance name on its own timeline and give the movieclip and
instance name however and whereever you place it.

you can apply event handlers to your movieclip and reference your textfield by
using movieclipInstanceName.textfieldInstanceName.
BobK101060
5/25/2004 2:58:43 PM
kglad
5/26/2004 1:04:20 AM
you can either apply code directly to the movieclip:

on(press){
this.gotoAndStop("down");
_root.gotoAndPlay(33);
}

or attached to a frame:

myMC_button.onPress=function(){
this.gotoAndStop("down");
_root.gotoAndPlay(33);
}
kglad
5/26/2004 2:59:58 PM
p.s. _level0.myLabelSymbol is your button instance and
_level0.myLabelSymbol.instance1 is the textfield within your button. you can't
give your textfield an instance name when it's on the button timeline (well,
actually you can give it an instance name but flash won't recognize it.) flash
will give the textfield an instance name. in your situation it was given the
name instance1.
you could assign text to your button's textfield by referencing:

yourbuttonInstanceName.instance1.text="button 1";
BobK101060
5/26/2004 3:06:44 PM
Thank you. That was not the answer I was hoping for, but the one I kind of
expected. I knew about being able to access the text field this way -
yourbuttonInstanceName.instance1.text="button 1"; . The fact that the system
assigns the value of the text fields instance name is my problem. I dynamically
create multiple instances of this symbol, so I need to know up front what that
text field reference name is. Instance# does not do it for me. Back to the
drawing board.
kglad
5/26/2004 4:40:25 PM
well, it's not really a set-back. you just have to use movieclip buttons
instead of buttons. as i mentioned above, making a movieclip with a textfield
in it works perfectly well. there are no limitations on this movieclip button
and it's easy to reference your textfield.
AddThis Social Bookmark Button