Showing 1 - 1 of 1 total. RSS Feed WordPress RSS Feed

Dispatch Custom Event passing parameters

You can't pass parameters using dispatchEvent in As3 so the best way to do it is to create a custom class that extend the Event class.
You'll dispatch the new event in this way:

var e:CustomEvent = new CustomEvent(CustomEvent.FORM_SUBMITTED, nameTxt.text, surnameTxt.text);
this.dispatchEvent(e);


Following the CustomEvent class:
package events
{

import flash.events.Event;

public class CustomEvent extends Event
{
public static const FORM_SUBMITTED:String = "FormSubmitted"

public var name:String;
public var surname:String;

public function CustomEvent( _type:String, _userName:String, _surName:String):void
{
super(_type);
this.name = _userName;
this.surname = _surName;
}


override public function clone():Event
{
return new CustomEvent(type, name, surname);
}
}
}


Showing 1 - 1 of 1 total. RSS Feed WordPress RSS Feed