Reputation: 1
The first thing I want to build is exit button. When you click this button there will be a pop up that warn you to exit the application. If you click yes you will exit the app but if you click no, the app will continue from the last frame before you click the exit button.
So far, I made this code :
import flash.system.fscommand;
stop();
cncl.addEventListener(MouseEvent.MOUSE_DOWN, cncl); //No_button
function cncl(event:MouseEvent):void {
prevFrame(); // i don't if this right or wrong
ext.addEventListener(MouseEvent.MOUSE_DOWN, ext); //Yes_button
function ext(event:MouseEvent):void {
fscommand("quit");
}
So, basically I just want if you cancel to exit, you back into the app.
Upvotes: 0
Views: 72
Reputation: 52133
There's no generic "go back to the frame you came from" command. You have to track this yourself. For example:
var lastFrame:int;
function goto(frame:int):void {
lastFrame = currentFrame;
gotoAndStop(frame);
}
function back():void {
gotoAndStop(lastFrame);
}
However, I should mention that frame navigation in general can get rather hard to manage. Especially for something like a popup confirmation, it's better to just dynamically show and hide a display object over top of the current frame.
Upvotes: 1