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 flexcoders@yahoogroups.com, "netdeep" <[EMAIL PROTECTED]> 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?
>


Reply via email to