Thanks for the reply Todd. What about processing the event though? For example if I have:
foo.addEventListener(MouseEvent.MOUSE_DOWN, processResult); But I want to define processResult so that I can pass it a number or an object, how do I use Custom events? The even I'm want to listen for is the moue down event. When I define this listener, I know the value I want to associate with that event. Later on, I won't know it so that when processResult gets called, it needs that extra parameter to work. I'm a bit confused about how to use the custom event there, since I won't be the one dispatching it. --- In [email protected], "twcrone70" <[EMAIL PROTECTED]> wrote: > > Create a custom event that has a field or fields that hold your > parameter(s). When you create the event for dispatching you can then > add the parameter(s) and since that event is passed in to the handler > method, you will have the parameter(s) in the event instance. > > >>> > package mypkg > { > import flash.events.Event; > > /** > * Custom event that holds extra data. Insipred by Cliff Hall's > PureMVC framework > * and usage of Notifications. > * > * @author Todd Crone > */ > public class CustomEvent extends Event > { > /** > * The data associated with the event. > */ > public var body:Object; > > /** > * Constructor. > * > * @param type > * The event type. > * @param body > * The body for this custom event. > * @param bubbles > * Whether or not this event bubbles up the component > hierarchy or not. > * @param cancelable > * Is this event cancelable by a listener. > */ > public function CustomEvent( type:String, > body:Object, > bubbles:Boolean = false, > cancelable:Boolean = false ) > { > super( type, bubbles, cancelable ); > > this.body = body; > } > > } > } > > <<< > > Hope this helps! > > - Todd > > > --- In [email protected], "netdeep" <deepnet@> wrote: > > > > > > I need to pass a parameter to a function using actionscript. > However by default, all you can > > pass are events to the function called by an eventlistener. I know > this is easy to do in MXML, > > but can it be done in actionscript? The documentation has this to > say about it: > > > > "Because the second parameter of addEventListener() is a function, > you cannot specify > > parameters of that function in the addEventListener() call. So, to > pass additional parameters > > to the listener function, you must define them in the listener > function and then call the final > > method with those parameters." > > > > But what does it mean to "call the final method with those > parameters". No examples are > > given. Could someone give me a quick example of how this is done? > > >

