# Shared Objects / array trouble

**URL:** <https://forum.kirupa.com/t/shared-objects-array-trouble/212174>\
**Category:** Uncategorized\
**Created:** [January 9, 2007, 12:34am UTC](https://forum.kirupa.com/t/shared-objects-array-trouble/212174 "2007-01-09T00:34:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rninne](https://avatars.discourse-cdn.com/v4/letter/r/bc8723/32.png) [@rninne](https://forum.kirupa.com/u/rninne)\
**Post date:** [January 9, 2007, 12:34am UTC](https://forum.kirupa.com/t/shared-objects-array-trouble/212174/1 "2007-01-09T00:34:50Z")

</div>

Hello,

I am having a spot of trouple with storing arrays in shared objects.

Here is an example of what I am trying to do.

[http://users.tpg.com.au/marman/arrayTest.fla](http://users.tpg.com.au/marman/arrayTest.fla)

The increase button populates an array (\_root.ar\_sm2), ie first time you press it 0,1 seccond time 0,1,1 thirs 0,1,1,1 you get the idea.

The save button stores the array in a shared object.

The load button recalls and displays the stored arrays in the text box.

The clear button sets all the nodes of \_root.ar\_sm2 to 0 for it’s length ie 0,0,0,0,0,0, whatever.

My problem is when you store the array to a shared object then clear \_root.ar\_sm2 the shared objects also gets cleared. Try increase, increase, increase, save, clear, load and you will see what I mean.

The reason I am doing this is to use the array to store how many objects I have on the stage ie attatchmovie. If I have 5 objects the array will read 0,1,1,1,1,1 and if I delete say object 3 (removemovieclip) it will then read 0,1,1,0,1,1. Then the user can save that array to a shared object (along with x and y coords for each item) clear the stage and reload it, or a different saved setting. Pretty neat huh?

I have written all the script for every thing else ie attatch and remove and it works perfectly so I don’t need assistance there it is just when I clear the array it also clears the shared object…

Any help as to why this is happening and also how I can prevent it would be appreciated.

Robert :kir:
