# Complex: Saving a clone to a Shared Object

**URL:** https://forum.kirupa.com/t/complex-saving-a-clone-to-a-shared-object/309379
**Category:** flash
**Created:** [May 13, 2010, 1:04pm UTC](https://forum.kirupa.com/t/complex-saving-a-clone-to-a-shared-object/309379 "2010-05-13T13:04:49Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![contrast](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@contrast](https://forum.kirupa.com/u/contrast)
#### Post date: [May 13, 2010, 1:04pm UTC](https://forum.kirupa.com/t/complex-saving-a-clone-to-a-shared-object/309379/1 "2010-05-13T13:04:49Z")

</div>

Edit:  
(I see this same type of question was posted almost three years ago with no resolution, does anyone have a solution now?  
[http://www.kirupa.com/forum/showthread.php?t=275764](http://www.kirupa.com/forum/showthread.php?t=275764))

I am trying to save a clone of a custom object (contains arrays and other custom objects as properties) to a Shared Object.

Basically I have a menu system that created this program, it’s running and at any point I want the user to be able to save it so he can go back to that exact point at a later date. Here is what I do so far:

1. Pause the program
2. The menu saves the variable that references the running program using a bytearray to a shared object
3. A a later time, to load the program I pull the data from the shared object and save it to a variable, which I then treat like the original program

Here is my code to save the data:

```auto
var byteArrayCloner:ByteArray = new ByteArray();
byteArrayCloner.writeObject(myProgram);
byteArrayCloner.position = 0;
mySharedObject.data["myProgram_Running"] = byteArrayCloner.readObject();
mySharedObject.flush();

```

But it doesn’t work correctly, when I save the data I get several #1034 errors:

TypeError: Error #1034: Type Coercion failed: cannot convert Object@12ee0421 to org.papervision3d.core.proto.MaterialObject3D.  
TypeError: Error #1034: Type Coercion failed: cannot convert Object@12f1d881 to flash.geom.Transform.

So I read how I am suppose to use “registerClassAlias” to remove those errors. I started adding them, like this:

```auto
registerClassAlias("SpriteAlias", Sprite);

```

The errors started to go away, I then tried:

```auto
registerClassAlias("TransformAlias", Transform);

```

This caused an error when I tried to save the data:

ArgumentError: Error #1063: Argument count mismatch on flash.geom::Transform(). Expected 1, got 0.  
at flash.utils::ByteArray/readObject()

I don’t use flash.geom.transform, but I do use TweenLite, which uses it. What am I doing wrong here? How do you save a custom object to a shared object without any errors?

Thanks for any help.
