Save movieclip location Rotation and x and y

190 views Asked by At

I was hoping you could help me ( I'm pretty new to AS3 ) I bumbling through and making gradual progress. I'm wanting to have it so that when I drag my movie clip x and y across the stage and rotate it, the rotation is saved to the sharedOject. It may also be worth noting that you can only rotate the draggable object in a certain mode - activated by a mouse click.

stop();
 // save functions

 var mySO:SharedObject = SharedObject.getLocal("iDesign");

 bones_mc.x = mySO.data.my_x;
 bones_mc.y = mySO.data.my_y;
 // ------ saves last rotation --- bones_mc.rotation = mySO.data.my_rot;

 if (!mySO.data.my_y) {
 bones_mc.x = 424;
 bones_mc.y = 119;
 }

save_btn.addEventListener (MouseEvent.CLICK, clickersave);

function clickersave (e:MouseEvent):void {
mySO.data.my_x = bones_mc.x;
mySO.data.my_y = bones_mc.y;
// ---- stops the spin mySO.data.my_rot = bones_mc.rotation;    
mySO.flush ();
}

bones_mc.buttonMode=true;

// UI btns TOOLS --------------------- 

Thanks!

1

There are 1 answers

0
Marcela On

I tested out your code by uncommenting the pertinent parts and it works just fine. I'm not sure where your exact problem is, but try this:

stop();
// save functions

var mySO:SharedObject = SharedObject.getLocal("iDesign");

bones_mc.x = mySO.data.my_x;
bones_mc.y = mySO.data.my_y;
bones_mc.rotation = mySO.data.my_rot;

if (!mySO.data.my_y) 
{
    bones_mc.x = 424;
    bones_mc.y = 119;
}

save_btn.addEventListener (MouseEvent.CLICK, clickersave);

function clickersave (e:MouseEvent):void 
{
    mySO.data.my_x = bones_mc.x;
    mySO.data.my_y = bones_mc.y;
    mySO.data.my_rot = bones_mc.rotation;    
    mySO.flush ();
}

bones_mc.buttonMode=true;