是否可以获取flash(AS3)中的所有成员变量?
我正在尝试获取 AS3 中的所有成员变量,然后对于每个我想以各种方式处理它的成员变量。我需要名称,然后如果它是某种类型的集合,我也想循环遍历该集合。我试图以某种自定义的方式进行本质上的序列化。 谢谢!
I am trying grab all the member variables in AS3, and then foreach one i would like to process it in various ways. I would need the name and then if it is a collection of some type I would like to loop through that collection as well. I am attempting to essentially serialize in a somewhat custom fashion.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想要序列化一个对象,您肯定会想使用 JSON。
JSON 基本上将对象转换为字符串,也使用encode()/serialize() 和decode()/deserialize() 函数将对象转换为字符串。
AS3 中有一个内置的 JSON 类,并且非常易于使用。
一旦你做了类似的事情:
获取字符串后,你可以执行所有开关逻辑来操作每个不同的变量,并通过 deserialize() 函数将其转换回对象。
If you're looking to serialize an object, you will definitely want to use JSON.
JSON basically converts objects into strings and also the other way round using an encode()/serialize() and decode()/deserialize() function.
There is a built-in JSON class in AS3, and it's really easy to use.
Once you do something like:
After getting the string, you can do all your switch logic to manipulate each of your different variables and convert it back into an object via the deserialize() function.
您可以使用describeType。它以 XML 形式返回有关该对象的信息。默认情况下,您可以迭代对象中的公共属性。您可以尝试类似...
我希望这能回答您的问题。
You could use describeType. That returns information about the object as XML. By default, you can iterate over public properties in objects. You could try something like...
I hope this answers your question.