问题
I was hoping someone could offer a simple solution. I am trying to save a 'labeled' frame on the timeline by storing it as a SharedObject.
The user can flip between various different backgrounds on the stage by clicking a button - button one corresponds to background one, background 2 corresponds to btn two and so on... For your reference these backgrounds are stored in a sub timeline. Any tips on how to get this to store..?
//// ---------------- WINDOW SWAPPER -------------------
this.but_one.btn_one.addEventListener(MouseEvent.CLICK, swapperslide);
function swapperslide(event:MouseEvent):void
{
this.caseSwapper.gotoAndStop("frametwo");
}
this.but_one.btn_two.addEventListener(MouseEvent.CLICK, swapperslidetwo);
function swapperslidetwo(event:MouseEvent):void
{
this.caseSwapper.gotoAndStop("framethree");
}
save_btn.addEventListener (MouseEvent.CLICK, clickersave);
// ---- saves -----------------------
function clickersave (e:MouseEvent):void {
mySO.data.myframe = timelineframe;
////mySO.data.my_y = bones_mc.y;
mySO.flush ();
}
Thanks
P.s the frames on the movie clip are also contain AS3 stop();
Edit updates to code -----------------------------
//SAVE FUNCTIONS ---------------------------------------
//---------------------------------------------------
//---------------------------------------------------
var mySO:SharedObject = SharedObject.getLocal("iDesign");
bones_mc.x = mySO.data.my_x;
bones_mc.y = mySO.data.my_y;
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.mybut_x = btrfly_mc.x;
mySO.data.mybut_y = btrfly_mc.y;
mySO.data.mytig_x = tiger_mc.x;
mySO.data.mytig_y = tiger_mc.y;
mySO.data.mybow_x = pink_bow_mc.x;
mySO.data.mybow_y = pink_bow_mc.y;
mySO.data.myblkbow_y = pink_bow_mc.y;
mySO.data.myblkbow_x = pink_bow_mc.x;
// tears saved - - - - - - -
mySO.data.mytear_drop_mc_three_x = tear_drop_mc_three.x;
mySO.data.mytear_drop_mc_three_y = tear_drop_mc_three.y;
mySO.data.mytear_drop_mc_one_x = tear_drop_mc_one.x;
mySO.data.mytear_drop_mc_one_y = tear_drop_mc_one.y;
mySO.data.mytear_drop_mc_two_x = tear_drop_mc.x;
mySO.data.mytear_drop_mc_two_y = tear_drop_mc.y;
mySO.data.mytear_drop_mc_four_x = tear_drop_mc_four.x;
mySO.data.mytear_drop_mc_four_y = tear_drop_mc_four.y;
mySO.data.myframe = caseSwapper.currentFrame;
trace(caseSwapper.currentFrame)
mySO.flush ();
}
//caseSwapper.currentFrame = mySO.data.myframe;
tear_drop_mc_three.x = mySO.data.mytear_drop_mc_three_x;
tear_drop_mc_three.y = mySO.data.mytear_drop_mc_three_y;
回答1:
In order to store the current frame, you need to use currentFrame
property.
mySO.data.myframe = caseSwapper.currentFrame;
回答2:
To store value in SharedObject, you must to get reference first:
function clickersave (e:MouseEvent):void {
var mySo:SharedObject = SharedObject.getLocal("SomeName");
mySo.data["my_y"] = bones_mc.y;
mySo.flush();
}
来源:https://stackoverflow.com/questions/22300939/as3-saving-a-sharedobject-timeline