Using generated ActionScript proxy from C #
Sorry if the title is unclear - not sure how to express it. Feel free to edit it.
I have a web service written in C # and it uses an enum. When I consume this web service using Flash, I had Flex creating proxy classes that also generates the specified enum in ActionScript. My problem is that I don't know how to use this generated ActionScript.
C # enum:
public enum ImageType
{
None = 0,
Png = 1,
Jpg = 2,
Gif = 3
}
ActionScript generated proxy class (can't change this):
public class ImageType
{
public function ImageType() {}
[Inspectable(category="Generated values", eumeration="None,Png,Jpg,Gif", type="String")]
public var _ImageType:String;public function toString():String
{
return _ImageType.toString();
}
}
An example using ActionScript (i.e. how it should work in my brain):
var imgType:ImageType = ImageType.Png; //this does not actually work though
NOTE. The code is just an example, but the structure is the same.
How can I use this ImageType enum in ActionScript?
source to share
AS3 does not support enums. I didn't immediately understand what the point of this generated proxy class is, but it won't provide much of the enumeration behavior you're used to.
You will need to do the following:
var imgType:ImageType = new ImageType();
imgType._imageType = "Png";
I know you said that you cannot change the generated class, but if you want to create your own enum class, check the following question for links to the official documentation, as well as a helpful blog post about custom enum implementation:
source to share