Yeah, the simplest way is to create an index field on the buttons
themselves, and then access that in the listener with
event.target.index.

―
Mike Keesey

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:flashcoders-
> [EMAIL PROTECTED] On Behalf Of dnk
> Sent: Tuesday, October 31, 2006 6:59 PM
> To: Flashcoders mailing list
> Subject: Re: [Flashcoders] AS 3 -> event args
> 
> Mike Chambers wrote:
> > 2 other options:
> >
> > Just have one event handler per button.
> >
> > or use an anonymous function
> >
> > myButton.addEventListener(MouseEvent.CLICK,
> function(){doSomething(1);});
> >
> > private function doSomething(index:int):void
> > {
> >     trace(index);
> > }
> >
> > (I havent tested the code above, so there might be some syntax
errors).
> >
> > Personally, I would always have one event listener per button as I
> > feel it make it a little easier to read the code.
> >
> > mike chambers
> >
> > [EMAIL PROTECTED]
> Hey - the anon function seems to be the way that resembles what I used
> to do. The only reason I do not have a unique one per button is say
for
> example I have 25 buttons and I loop through to create the instances
and
> the event listeners - then have a function that performs the same
> actions (with a different index number). Then I only have to write out
1
> function for the 25 button instances. Unless there is a way to do it
> with a loop, I would then have to write out 25 unique functions to
> handle the button events - correct? That is if I was going to do it
your
> preferred way with unique button functions....
> 
> Dustin
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> 
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to