But you may not need a custom event.  

 

Folks tend to forget the all event handlers have access to the object
that raised the event via the target and currentTarget properties.  

 

So if you expose the ID and Type as public properties on your class, you
can access them in the handler.  Much simpler than a custom event.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Nate Pearson
Sent: Wednesday, April 30, 2008 2:38 PM
To: [email protected]
Subject: [flexcoders] Re: Raising Events with Properties

 

You are freaking awesome! Thanks for giving me that example!

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "caffeinewabbit"
<[EMAIL PROTECTED]> wrote:
>
> You'll need to extend event and create a custom child class.
> 
> Custom event code:
> 
> package my.package.path
> {
> import flash.events.Event;
> 
> public class MyEvent extends Event
> {
> public static const PROJECT_SELECTED:String = "projectSelected";
> 
> public var projectID:Number;
> public var projectType:Number;
> 
> public function MyEvent(type:String, projectID:Number,
> projectType:Number)
> {
> this.projectID = projectID;
> this.projectType = projectType;
> super(type);
> }
> }
> }
> 
> In your metadata:
> 
> <mx:MetaData>
> [Event(name="projectSelected",type="my.package.path.MyEvent")]
> </mx:MetaData>
> 
> In your code:
> 
> dispatchEvent(new MyEvent(MyEvent.PROJECT_SELECTED, projectID,
> projectType));
> 
> HTH,
> --G
> 
> --- In [email protected]
<mailto:flexcoders%40yahoogroups.com> , "Nate Pearson" <napearson99@>
wrote:
> >
> > I want to raise an event with some custom properties.
> > 
> > Here's my event name:
> > 
> > <mx:Metadata>
> > [Event(name="projectSelected")]
> > </mx:Metadata>
> > 
> > 
> > In code I say:
> > 
> > dispatchEvent(new Event("projectSelected"));
> > 
> > Now I want to send a ProjectID and ProjectType with the event. Is
> > this possible? Maybe a custom event? Not sure how to do that
though...
> >
>

 

Reply via email to