0

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;
user3082874
  • 61
  • 2
  • 11

2 Answers2

1

In order to store the current frame, you need to use currentFrame property.

mySO.data.myframe = caseSwapper.currentFrame;
Vesper
  • 18,599
  • 6
  • 39
  • 61
  • Hello thanks for the heads up. I have tried to use this piece of script but nothing happens. The frames are buried in caseSwapper.frameone I tried this path - no luck. Do you have any other ideas? – user3082874 Mar 10 '14 at 15:16
  • 1
    Did you implement load routine? Did you `trace(caseSwapper.currentFrame)`? – Vesper Mar 11 '14 at 04:51
  • Good idea! It shows '1' '2' '3' to the corresponding frames yet fails to actually store the data toe the sharedObject if that makes sense? Any ideas how to make it stick – user3082874 Mar 11 '14 at 10:46
  • Well, it'll make sense if your storing function does NOT have access to `caseSwapper`, otherwise do `trace(mySO.flush());` and check if the result is "flushed". If the result is "pending", check your Flash player shared data storage settings. If something else, you're probably in a world of pain. – Vesper Mar 11 '14 at 12:50
  • oh dear.... looks like a world of pain on the horizon. Trace results added below. 3 flushed I might need to rethink this method. Thanks, – user3082874 Mar 11 '14 at 13:06
  • Then you need to load the data off your shared object properly. "flushed" means that you've made it, and the data is properly stored. But this data is not immediately available in your display list once you load the SWF, it first has to parse the shared object's existing data (if any, so make sure you have error handling code in there!), then apply proper numbers to correct properties of your display list hierarchy. Loading is not an easy task, because you need to first check, then assign properties, and you must make sure that the save routine won't fire before you check for data. – Vesper Mar 11 '14 at 13:12
0

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();
}
Nicolas Siver
  • 2,875
  • 3
  • 16
  • 25
  • Hello, I think I have already declared this. I tried placing the script inside the function and it threw back errors. – user3082874 Mar 11 '14 at 10:43
  • What errors do you have exactly? Also check this answer with [SharedObject](http://stackoverflow.com/questions/22290999/how-to-display-movie-clip-if-shared-object-is-equal-to-a-number-as3/22295654#22295654) – Nicolas Siver Mar 11 '14 at 11:12