# How do I get link command to correct btn?

**URL:** <https://forum.kirupa.com/t/how-do-i-get-link-command-to-correct-btn/303469>\
**Category:** flash\
**Created:** [January 20, 2010, 8:30pm UTC](https://forum.kirupa.com/t/how-do-i-get-link-command-to-correct-btn/303469 "2010-01-20T20:30:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![oluc](https://avatars.discourse-cdn.com/v4/letter/o/cc9497/32.png) [@oluc](https://forum.kirupa.com/u/oluc)\
**Post date:** [January 20, 2010, 8:30pm UTC](https://forum.kirupa.com/t/how-do-i-get-link-command-to-correct-btn/303469/1 "2010-01-20T20:30:29Z")

</div>

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.

```auto

                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!
