I created a simple username page, in frame 1, there is a button and input text
like the code below
stop();
var SOlastFrame: SharedObject = SharedObject.getLocal("save_frame2");
var shared_data: String
next.addEventListener(MouseEvent.CLICK, gotomyNextFrame);
function gotomyNextFrame(e: MouseEvent): void {
shared_data = inputName.text
nextFrame()
SOlastFrame.data.lastframe = currentFrame;
SOlastFrame.flush();
}
if (SOlastFrame.data.lastframe != null) {
gotoAndStop(SOlastFrame.data.lastframe);
}
i saved the last frame by adding this code
SOlastFrame.data.lastframe = currentFrame;
SOlastFrame.flush();
so that I can jump to the last frame I opened, I added this code
if (SOlastFrame.data.lastframe != null) {
gotoAndStop(SOlastFrame.data.lastframe);
}
at frame 2, I put dynamic text with code like this
var SOnameUser: SharedObject = SharedObject.getLocal("saveName");
SOnameUser.data.yourName = shared_data;
SOnameUser.flush();
trace(SOnameUser.data.yourName);
userName.text = "Hello " + shared_data;
if (shared_data != null) {
userName.text = shared_data;
SOnameUser.data.yourName = shared_data;
}
I think it works, dynamic text is saved successfully. If I reopen it, it will go directly to frame 2 because of the execution result SOlastFrame.data.lastframe.
the problem is that the username that I saved earlier turns to null.
how can i load dynamic text on shareobject when SOlastFrame.data.lastframe is executed.
or
how to load sharedObject when flash is reopened
You get it like that because when you start 2-nd time you go straight to the frame 2 where the shared_data is empty. I think you should re-organize... well, everything.
Then, this is your frame 1.
Then, here we go.