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); }