Serializing enums in FDS

Java 5.0 introduced typesafe enums which are a special type of class. enums in other languages are typically just an ordered set of properties, however, Java enums allow custom behaviors and logic to be added through constructors, fields and methods.

FDS is based on JDK 1.4.2 and does not natively support enums. ActionScript 3 does not have the concept of enums either. To FDS, an enum class definition looks like a normal class. As such, only public fields and public bean methods with get/set accessors are seen as properties.

An enum can be written to capture the selected value by making the class look like a normal value Object.


package food;

public enum FruitEnum
{
    APPLE("apple"),
    ORANGE("orange"),
    BANANA("banana");

    FruitEnum(String value)
    {
        this.value = value;
    }

    public String value;
}

While this doesn’t provide round trip support for enums, it does allow Java to ActionScript conversions of enums.