View Full Version : Multiple button actions
colio
December 5th, 2005, 03:49 AM
i have n nos of btn's on stage .on clicking any btn i want to duplicate a movie clip on stage "circle_mc" & place d copy with equal spacing along y axis...
i dont want to manually put the actions on each btn.the actions can be put on the timeline ...like btn.onRelease = function(){ //.......actions}
the btns r given instance names btn0,btn1...so on..
pls help.
e.s.x.s
December 5th, 2005, 03:54 AM
for(i=0; i<YourButtonNumber; i++){
_root["btn"+i].onRelease = function(){
//.. your actions
}
}
colio
December 5th, 2005, 04:29 AM
well thanks for d reply ..but the thing is its not working as desired..
here is d action.well for the cmd trace("dupMC"+a);it gives o/p dupMC4 for d click of any button.
for (a=0; a<4; a++) {
_root["btn"+a].onRelease = function() {
trace(eval("btn"+a));
duplicateMovieClip("circle_mc", "dupMC"+a, a);
trace("dupMC"+a);
_root["dupMC"+a]._y = a*50;
trace(eval(_root["dupMC"+a]._y));
}
}
pls help
eki
December 5th, 2005, 05:37 AM
for (a=0; a<4; a++) {
_root["btn"+a].a= a;
_root["btn"+a].onRelease = function() {
trace(eval("btn"+a));
duplicateMovieClip("circle_mc", "dupMC"+this.a, _root.getNextHighestDepth());
trace("dupMC"+a);
_root["dupMC"+this.a]._y = this.a*50;
trace(_root["dupMC"+this.a]._y);
}
}
Barn
December 5th, 2005, 01:08 PM
And the reason for that is that variables that are accessed within button event handlers are evaluated at the time the button event occurs, NOT at the time the button event handler is created.
eki
December 5th, 2005, 01:23 PM
:thumb2:
colio
December 6th, 2005, 12:13 AM
thanx dude it worked very fine.. thanx all. :)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.