One way would be to create a subclass of Event that stores the
parameters.

In this case, though, I wouldn't even do that. You can just use
event.target to determine which button was pressed:

function onPressed(event:Event):void {
        var button:Button = Button(event.target);
        // Do stuff with button.
}

If you need to specifically use an index number, I'd attach that to the
button instances themselves. Then you could retrieve that via
event.target.
―
Mike Keesey

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:flashcoders-
> [EMAIL PROTECTED] On Behalf Of dnk
> Sent: Friday, October 27, 2006 7:59 PM
> To: Flashcoders mailing list
> Subject: [Flashcoders] AS 3 -> event args
> 
> Hi there. I am just beginning my adventure into AS 3, and came upon
> something.
> 
> In AS 2 I used to use a custom delegate class to deal with scope
issues,
> but also be able to pass args (in an array, single string, etc) to my
> event functions.
> 
> So for example, I might have something in AS 2:
> 
> // snipped fro ma method
> for (var j:Number = 0; j < 5; j++) {
>             this._targetMc["dtBtn" + j].onPress =
> MyDelegate.create(this, onPressed, j);
>         }
> 
> 
> // event method
>     function onPressed(i:Number) {
>         trace(i);
>     }
> 
> So the custom class would allow this to work in my classes.
> 
> Now in AS 3 as I have read, the basic delegate class is no longer
needed
> as the scope issues are dealt with now.
> 
> So how would I go about accomplishing the same thing in AS 3?
> 
> passing an arg to an event method?
> 
> Thanks!
> 
> 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