PDA

View Full Version : having trouble adding action to a button...


uzairrahim
10-31-2006, 11:04 PM
ok this is the sitation...

i have an empty movie clip inside a component i am using following script to attach a Button from library to the movie clip...

mc_pbHolder.attachMovie(popupVar, popupVar+1, 2);

so far so good,

now when i am try to add a simple script to the button nothin happens...this is what i m trying...

mc_pbHolder.popupVar.onRelease = function(){
trace("whatever")
}

when i try mc_pbHolder.onRelease = function(){
trace("whatever")
}
it obviously adds the script to the movieclip and the button rollover effect does not work....this is not what i wont

HELP!!!!!!!!!!!!!!

FrodoBaggins
11-01-2006, 03:11 PM
the first two parameters for attachMovie() should be a string for starters, but I'm not bitching if it works :P

mc_pbHolder.popupVar.onRelease = function(){
trace("whatever")
}
This doesn't work, since you've got as a name for your attached movie popupVar+1, so there is no button named popupVar.

when you run your script you can use Debug > List objects ... to see which objects are on your stage at that time. This is an easy way to figure out whether or not you're using the right references to your MC instances.

uzairrahim
11-01-2006, 07:01 PM
the first two parameters for attachMovie() should be a string for starters, but I'm not bitching if it works :P

mc_pbHolder.popupVar.onRelease = function(){
trace("whatever")
}
This doesn't work, since you've got as a name for your attached movie popupVar+1, so there is no button named popupVar.

when you run your script you can use Debug > List objects ... to see which objects are on your stage at that time. This is an easy way to figure out whether or not you're using the right references to your MC instances.

popupVar is a variable which holds a string value of the name of the button.

I figured out what the problem was, i wasnt naming the attached instance properly.

mc_pbHolder.attachMovie(popupVar, "popupButton", 2);
worked just fine

FrodoBaggins
11-02-2006, 08:46 AM
haha, doh!