
Welcome Guest
|
|
|
#1
|
|||
|
|||
|
AS3 Button Question
Hey all,
My problem is this: I have a flash file in which I'm adding MovieClips dynamically as buttons using a for loop. With each iteration I add a new button, give it a name and add an event listener. My question is, with this method, how do I know which button was clicked? In other words, say my for loop executes 5 times, adding 5 different buttons at 5 different locations on the stage. Is there anyway from within the code to determine which button was pressed? I feel like there should be a simple way to figure it out and I'm just missing it. The code looks like this: for (var aCount:String in pNameArray){ this["btn" + m1Count] = new buttonMC(); this["btn" + m1Count].addEventListener(MouseEvent.MOUSE_OVER, select); this["btn" + m1Count].addEventListener(MouseEvent.MOUSE_OUT, leave); this["btn" + m1Count].addEventListener(MouseEvent.CLICK, goTo); this["btn" + m1Count].buttonMode = true; this["btn" + m1Count].name = "btn" + m1Count; addChild(this["btn" + m1Count]); } Any tips or ideas would be greatly appreciated. Thanks. |
|
#2
|
||||
|
||||
|
Something like this
Actionscript:
function goTo(e:MouseEvent):void{
trace("Clicked:"+e.target.name)
}
__________________
.:To me AS is like LEGO, Only for the big Kids :. - Site - Blog - Glasgow Flasher - Activeden - bringmadeleinehome.com |
«
Previous Thread
|
Next Thread
»
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| simple as3 question. | fhickler | Newbies |
2 | 02-25-2008 04:39 PM |
| Basic AS3 question... | Ultra | Flash CS3 / Flash 9 |
7 | 10-09-2007 10:43 PM |
| Button/ Animation/ Simple Question | grafx | Newbies |
5 | 09-28-2006 01:27 PM |
| button scripting question | stephenMQ | Flash MX |
3 | 06-13-2003 05:57 PM |
| Button Overstate Question | pollywaffle | General Flash | 4 | 12-02-2002 12:18 PM |




