LOADING
Loading
Hi , welcome back.
LogoutLOGOUT
 
  Lost password?  
Hi
 




 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-14-2012, 09:53 PM
jth133 jth133 is offline
Registered User
 
Join Date: Jun 2010
Posts: 4
Rep Power: 0
jth133 is on a distinguished road
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.
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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




All times are GMT. The time now is 02:14 PM.