我们来看这样一个例子:
复制代码 代码如下:
private function test() : void {
var canvas :Canvas = new Canvas();
canvas.width = 100;
canvas.height = 100;
// 保存到ByteArray
var b : ByteArray = new ByteArray();
b.writeObject(canvas);
// 取出对象
b.position = 0;
var o : Object = b.readObject();
var c : Canvas = objectToInstance(o,Canvas) as Canvas;
trace(c.width);
trace(c.height);
this.addChild(c);
}
时间: 2024-11-05 21:46:30