ActionScript 3.0

ActionScript Enums

I found myself almost posting an article about how to fake Enum’s in ActionScript, when Sam Rivello pointed me to an existing and very lightweight implementation by Scott Bilas.

Browsing around a little bit more, I found a couple of more details relating to Scott’s implementation and things that could be added to the lightweight implementation by Scott.

One is Barney Boisvert’s addition of having the static constructor to prohibit the construction of instances other than the static constants instantiated at class loading time.

Both of these suggestions definitely beat the default implementations for Enums which involve using value types such as string and numeric values… so check it out if you are tired of using string literals in place of Enums.

3 thoughts on “ActionScript Enums

    1. Hi Sam,

      Thanks for your contribution – and its great to hear from you again… I too am a great fan of Enums (obviously)..
      Stay in touch.

      // Peter

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s