Is there an efficient way to assign the following switch statement to two different buttons (movie clips)?
btn.onRelease = function() {
switch (button_var) {
case 1 :
button_var = 2;
ball.slideTo(450, 100, 1);
break;
case 2 :
button_var = 3;
ball.slideTo(450, 150, .5);
break;
case 3 :
button_var = 4;
ball.slideTo(100, 150, 1);
break;
case 4 :
button_var = 1;
ball.slideTo(100, 100, 1);
break;
}
};
TIA
what exactly are you trying to do
I’m looking to have two different ways to make movieclips move. One is to click on movieclips themselves and the other is to click on forward/back buttons. Make sense?
var root:MovieClip = this;
var values:Array = [];
values["btn1"] = [["ball", 450, 100, 1], ["ball", 450, 150, .5], ["ball", 100, 150, 1], ["ball", 100, 100, 1]];
values["btn2"] = [["ball", 100, 50, .5], ["ball", 100, 150, 1], ["ball", 150, 10,.5], ["ball", 50, 50, 1]];
function runSwitch():Void {
this.button_var = this.button_var+1 || 0;
var item:Array = values[this._name][this.button_var%values[this._name].length];
root[item[0]].slideTo(item[1], item[2], item[3]);
}
function setUpActions():Void {
for (var i in values) root*.onRelease = runSwitch;
}
setUpActions();
