使用 C# 生成的 Actionscript 代理枚举
抱歉,如果标题不清楚 - 不知道如何措辞。 请随意编辑它。
我有一个用 C# 编写的 Web 服务,它使用枚举。 当我使用 Flash 使用此 Web 服务时,我让 Flex 生成代理类 - 它还在 Actionscript 中生成所述枚举。 我的问题是我不知道如何使用这个生成的 Actionscript。
C# 枚举:
public enum ImageType
{
None = 0,
Png = 1,
Jpg = 2,
Gif = 3
}
Actionscript 生成的代理类(无法更改此):
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();
}
}
Actionscript 使用示例(即,这就是它在我大脑中的工作方式):
var imgType:ImageType = ImageType.Png; //this does not actually work though
注意:代码仅是示例,但结构是相同的。
我将如何在 Actionscript 中使用这个 ImageType 枚举?
Sorry if the title is unclear - not sure how to phrase it. Feel free to edit it.
I have a web service written in C# and it uses an enum. When I am consuming this webservice with Flash, I had Flex generate the proxy classes - which also generates said 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 (cant 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();
}
}
Actionscript usage example (ie. this is how it should work in my brain):
var imgType:ImageType = ImageType.Png; //this does not actually work though
NOTE: Code is example only, but the structure is the same.
How would I go about using this ImageType enum in Actionscript?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AS3 不支持枚举。 我不能立即确定这个生成的代理类的意义是什么,但它不会提供您习惯的很多枚举行为。
您必须执行以下操作:
我知道您说过您无法更改生成的类,但如果您想创建自己的枚举类,请检查以下问题以获取官方文档的链接以及有关自定义的有用博客文章枚举实现:
AS3/Flash/Flex 中的枚举?
AS3 does not support enumerations. I'm not immediately sure what the point of this generated proxy class is, but it isn't going to provide much of the enum behavior you're used to.
You'd have to do the following:
I know you said you cannot change the generated class, but if you wanted to create your own enumeration class, check the following question for links to official documentation as well as a helpful blog post on a custom enum implementation:
Enums in AS3 / Flash / Flex?