# Movieclip Array Shared Objects

**URL:** <https://forum.kirupa.com/t/movieclip-array-shared-objects/295113>\
**Category:** flash\
**Created:** [August 25, 2009, 2:51pm UTC](https://forum.kirupa.com/t/movieclip-array-shared-objects/295113 "2009-08-25T14:51:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kekekiko](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kekekiko](https://forum.kirupa.com/u/kekekiko)\
**Post date:** [August 25, 2009, 2:51pm UTC](https://forum.kirupa.com/t/movieclip-array-shared-objects/295113/1 "2009-08-25T14:51:59Z")

</div>

Hi,

I have managed to find enough on the web to create something that will save and load the position of a movieclip using shared objects but I was wondering if there was a way to do it so that I could save all the positions of the moveclips on stage in one shared object rather than writing one for each movieclip.

I’m guessing it can be done through an array but am getting muddled with what to do!

Here is the code for the single clip that works fine:

mySharedObject = SharedObject.getLocal(“savedObject”);  
saveButton.onRelease = function() {  
mySharedObject.data.myMCX = myMC.\_x;  
mySharedObject.data.myMCY = myMC.\_y;  
mySharedObject.flush();  
};  
loadButton.onRelease = function() {  
myMC.\_x = mySharedObject.data.myMCX;  
myMC.\_y = mySharedObject.data.myMCY;  
};

And then here is the messed and muddled array:

mySharedObject = SharedObject.getLocal(“savedObject”);  
saveButton.onRelease = function() {  
mc1posx = my1MCX = my1MC.\_x;  
mc1posy = my1MCY = my1MC.\_y;  
mc2posx = my2MCX = my2MC.\_x;  
mc2posy = my2MCY = my2MC.\_y;

```
dataArray = new Array (mc1posx,mc1posy,mc2posx,mc2posy);
mysharedObject.data.dataArray = dataArray;

```

mySharedObject.flush();  
};  
loadButton.onRelease = function() {  
my1MC.\_x = mySharedObject.data.my1MCX;  
my1MC.\_y = mySharedObject.data.my1MCY;  
my2MC.\_x = mySharedObject.data.my2MCX;  
my2MC.\_y = mySharedObject.data.my2MCY;  
};

Any help greatly appreciated!
