Saving Sprites or Shapes with ByteArray

I’m trying to find a way to save vector drawing information made in a flash application in external files.

Basically, I have a simply vector drawing application - I want to put this on a server and have a way for users to “save” the graphics data on the server for later viewing.

I thought it would make sense to throw the “canvas” Shape object into binary format and then save it on the server via some external PHP.

The trouble is, I can’t seem to recover the Shape object from the binary data… it’s always “null.”

Here’s the idea:


var testClip:Shape = new Shape();
testClip.graphics.beginFill(0xFF0000);
testClip.graphics.drawRect(0,0,100,100);
testClip.graphics.endFill();
stage.addChild(testClip);

var byteClip:ByteArray = new ByteArray();
byteClip.writeObject(testClip);

byteClip.position = 0;
var newTestClip:Shape = byteClip.readObject as Shape;
stage.addChild(newTestClip);

Any ideas? I know saving bitmaps would be simple, but I’d like to keep things vector if possible.

Thanks!