actionscript-3flashvariablesshared-objects

flash as3 timeline animation storing value


I set a value on frame 20 of my animation

var final_answer = hundreds.text+tens.text+units.text;
var mySharedObject:SharedObject = SharedObject.getLocal("/");

I want to access this on frame 40 but I get the following error

Scene 1, Layer 'Actions', Frame 210, Line 5 1120: Access of undefined property mySharedObject.

I have also tried to use a normal variable - is there anyway to store a variable in what is effectively a cookie between frames?

Solution

  • I suggest you to use document class but if you don't want and handle all in the first frame you can use addFrameScript

    addFrameScript(4,onFrame5);
    
    function onFrame5():void{
        trace('current frame is 5');
    }