Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Some other languages, like Java, have a facility built into the language for Enums. But alas, ActionScript does not. So, what are Enums, exactly, and why do we care?
Enums are a way of enumerating all the possible values for a data
field as static members of a class. As an example, let’s look at the
simplest way to handle enumerating the valid values for the type property of the StoryVO.
What would be wrong with something like this?
package com.futurescale.sa.model.constant
{
public class StoryConstants
{
public static const SIMPLE:String = "0";
public static const NORMAL:String = "1";
public static const COMPLEX:String = "2";
}
}
Nothing would be wrong with it at all, but there are a few things that would be nice to have.