简体   繁体   中英

Save movieclip location Rotation and x and y

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!

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM