Accessing a static member has nothing to do with the constructor; so you won't have any performance issues.
If the event in question is a custom event, the convention is to declare the string constants for all events of a particular class of event (subclass of flash.events.Event
) in that event subclass itself. For example, all mouse event constants are declared in MouseEvent
, all menu related events are defined in MenuEvent
etc.
This convention will help you in code-completion if you're using the Flex mxmlc compiler. Let's say you have added the following metadata tag on top of a class definition (MyClass).
[Event(name="randomEvent", type="com.domain.events.CustomEvent")]
public class MyClass extends EventDispatcher { }
Now you declare an instance of this class and type in addEventListener:
var myClass:MyClass = new MyClass();
myclass.addEventListener(
You'll get CustomEvent.RANDOM_EVENT
in the autocomplete dropdown list. Without the metadata tag, it will just give you the two default items (activate and deactivate). The metadata tag tells the compiler that this class dispatches an event of class CustomEvent
and type randomEvent
- and the compiler assumes that the string constant is defined as per convention and gives you CustomEvent.RANDOM_EVENT as the option.
Auto-completion might still work if you declare string constant in SomeOtherClass
and provide the name of that class in the metadata tag - but that would be misleading as the class in question does not dispatch any event of SomeOtherClass