Hello.
I have a total of 11 buttons each named b1, b2, b3 etc. I used to have it so when the a button is clicked, the button was recognized as to which one it was through an array and string and switch statement (I will show you below). But now I have to introduce something in the middle and so I am not sure how to make it work any more.
public function addButtonEffects():void {
//the buttons used to lead to onButtonClick as you can see here
//but now I need them to lead to closeShutters and from there go to onButtonClick
b1.addEventListener(MouseEvent.CLICK,onButtonClick);
b2.addEventListener(MouseEvent.CLICK,onButtonClick);
b3.addEventListener(MouseEvent.CLICK,onButtonClick);
b4.addEventListener(MouseEvent.CLICK,onButtonClick);
b5.addEventListener(MouseEvent.CLICK,onButtonClick);
b6.addEventListener(MouseEvent.CLICK,onButtonClick);
b7.addEventListener(MouseEvent.CLICK,onButtonClick);
b8.addEventListener(MouseEvent.CLICK,onButtonClick);
b9.addEventListener(MouseEvent.CLICK,onButtonClick);
b10.addEventListener(MouseEvent.CLICK,onButtonClick);
b11.addEventListener(MouseEvent.CLICK,onButtonClick);
}
public function closeShutters(e:Event):void {
//this is the function I have introduced that makes the logic not work anymore
TweenMax.to(backgroundTop, 1.2, {y:512, ease:Quad.easeInOut, onComplete:onButtonClick});
TweenMax.to(backgroundBottom, 1.2, {y:511, ease:Quad.easeInOut});
}
public function onButtonClick(e:Event):void {
//as you can see with the two line below the switch statement recognizes the button through the button name
//so the question is how do I still get the buttons recognized even though I introduced the function above that has the tween?
var namesArray:Array = ["b1","b2","b3","b4","b5","b6","b7","b8","b9","b10","b11"];
var buttonWanted:String = namesArray[Number(e.currentTarget.name)];
//var sprite:Sprite = Sprite(e.currentTarget);
//var topPosition:uint = imageLoaderHost.numChildren -1;
//var numAbsolute:Number = Math.abs(imageLoaderHost.x);
switch (buttonWanted) {
case "b1" :
break;
//etc
Do you know how to change this to make it work?
Thanks for any help or direction!