Added to Simon's answer, if you want to avoid 'loosely referenced' event names and define your own ones, here's a few different propositions of conventional ways to use those:
1. Creating a custom event subclassing flash.events.Event
Probably the most conventional and obvious way even though being a bit of waste of code.
package transitions.events
{
import flash.events.Event;
public class MyTransitionEvent extends Event
{
public static const TRANSITION_INIT : String = "events.TransitionEvent.transitionInit";
public static const TRANSITION_PROGRESS : String = "events.TransitionEvent.transitionProgress";
public static const TRANSITION_COMPLETE : String = "events.TransitionEvent.transitionComplete";
public function MyTransitionEvent(type : String, bubbles : Boolean, cancelable : Boolean)
{
super(type, bubbles, cancelable);
}
override public function clone() : Event
{
return new TransitionEvent(type, bubbles, cancelable);
}
}
}
2. Defining event names as static constants from within the event dispatcher (e.g. subclass of Sprite or MovieClip)
To make things clearer, the event types should exclusively be defined from within the class the events are dispatched.
package
{
import flash.events.Event;
import flash.events.EventDispatcher;
public class Transition extends EventDispatcher
{
public static const TRANSITION_INIT : String = "events.TransitionEvent.transitionInit";
public static const TRANSITION_UPDATE : String = "events.TransitionEvent.transitionUpdate";
public static const TRANSITION_COMPLETE : String = "events.TransitionEvent.transitionComplete";
public function Transition()
{
}
private function init() : void
{
dispatchEvent(new Event(TRANSITION_INIT))
}
}
}
3. Reuse the native flash.events
Fortunately, the predefined events (i.e. flash.events.Event, flash.events.StatusEvent, flash.events.NetStatusEvent, etc.) are covering the most of the possible cases. So, for the sake of not reinventing the wheel and save some precious lines of code, if you find one matching your requirements, just reuse it.
package
{
import flash.events.Event;
import flash.events.EventDispatcher;
public class Transition extends EventDispatcher
{
public function Transition()
{
}
private function init() : void
{
dispatchEvent(new Event(Event.INIT));
}
private function change():void
{
dispatchEvent(new Event(Event.CHANGE));
}
private function complete():void
{
dispatchEvent(new Event(Event.COMPLETE));
}
}
}