我要做的是遍历一个对象,该对象也是一个复杂的对象树,并输出创建实例化和填充该对象及其所有子对象所采用(或采用)的 actionscript 3 代码。
例如,如果您在调试器中看到类似的内容
myObjectToParse (ParseMe@173e239)
----------[0]someBlob (SomeBlob@173e322)|null
----------[1]someChildren (Array@173e239)
--------------------[0]childFoo (ChildFoo@123e239)
------------------------------someProperty (Number@173e239) | 45
------------------------------someOtherProperty (Number@173e239) | 45
--------------------[1]childBar (ChildFoo@123e239)
------------------------------someStringProperty(String@173e239) | "hello world"
出口商会吐槽:
public class MySerialized extends ParseMe
{
public var someBlob:SomeBlob;
public var someChildren:Array;
public function MySerialized()
{
//populateSomeBlob(); //its null so the export doesn't write it out
populateSomeChildren();
}
private function populateSomeChildren()
{
someChildren=new Array(2);
var childFoo:ChildFoo=new ChildFoo();
childFoo.someProperty=45;
childFoo.someOtherProperty=45;
childFoo.someProperty=45;
childFoo.someOtherProperty=45;
var childBar=new ChildBar();
childBar.someStringProperty="hello world";
someChildren[0]=childFoo;
someChildren[1]=childBar;
}
}
有小费吗?想法?谢谢!
编辑:我想我最终可能只是尝试序列化为 amf ByteArray ......听起来更简单,但我没有玩过,也不知道它可以深入多少层以及它支持哪些类型的引用。