I have a drag and drop project where the user can drag copies of a MovieClip, and I would like to know how to save and load the position of the draggable copies using the SharedObject class. I currently use SharedObject with a save and a load button. But it only saves the position of the last dragged MovieClip copy.
How do I save the position of the MovieClip copies on stage, so that when I click the load button it loads the position of all copies as they were positioned when I clicked the save button?
Code:
latestClone.addEventListener(MouseEvent.MOUSE_DOWN, onCloneClick);
function onCloneClick(e:MouseEvent):void
{
var target:MovieClip = e.currentTarget as MovieClip;
latestClone = target;
}
}
save.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
function fl_MouseClickHandler(event:MouseEvent):void
var mySo:SharedObject = SharedObject.getLocal("SaveData");
mySo.data.my_x = latestClone.x;
mySo.data.my_y = latestClone.y;
mySo.flush();
}
loader.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_2);
function fl_MouseClickHandler_2(event:MouseEvent):void
{
var mySo:SharedObject = SharedObject.getLocal("SaveData");
latestClone.x = mySo.data.my_x;
latestClone.y = mySo.data.my_y;
}