Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

3. Modelling the Domain > Creating the Enums

Creating the Enums

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.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial