Do custom Event type identifiers in as3 need to be unique?

actionscript-3, event-handling, events, uniqueidentifier

Solution

You can definitely run into collisions with this. This will be very evident if you use bubbling, or listen for both events on the same object. At the core, the event listeners are listening for a string. There is no strong typing, just a if(string==type) check (this is over simple, but essentially what is happening).

it would be proper to name these event types:

public static const EVENT_TYPE_ONE:String = "eventTypeOne";

If you make use of any `[Event(name="eventTypeOne", type="com.me.events.CustomEvent")]` this syntax is essential.

Problem

Say I have two classes which extend `Event`: ``` public class CustomEventOne extends Event { public static const EVENT_TYPE_ONE:String = "click"; //... rest of custom event ``` and ``` public class CustomEventTwo extends Event { public static const EVENT_TYPE_TWO:String = "click"; //... rest of custom event ``` Is it ok that they both declare an event type using the same string `"click"`? Or do event type identifiers need to be unique throughout the application?

Original source