AS3 SharedObject - last frame

Hi,

Im trying to use the SharedObject to allow the user to return back to where they previously were in the game if they click away…

I’ve used the following code however It just seems to stick to the next frame. i.e frame 1= start and frame 2 =intro… it just seems to stick to the intro frame each time i return? I’ve
Does anyone have any solutions or a different approach?

on first frame:

import flash.net.SharedObject;

var mySharedObject:SharedObject = SharedObject.getLocal(“lastFrame”);

var gotoLastFrame = mySharedObject.data.gotoLastFrame;

if(mySharedObject.data.gotoLastFrame){
gotoAndPlay(gotoLastFrame);
}

And on each major frame I have:

mySharedObject.data.gotoLastFrame = currentFrame;

mySharedObject.flush();

Thanks in advance!