So i am making a game using the Flashpunk framework for AS3, and i can't seem to figure out how to terminate the program execution when the user clicks an exit button. I have tried using both System.exit(0)
and fscommand("quit")
, but neither of these work in the release build (the former only works in debug mode, the latter doesn't work at all). Does anyone know how to code an exit button in Flashpunk?
Here is my code:
import flash.system.*;
public class Story extends World
{
var btnDone:Button = new Button(FP.screen.width * 9 / 10, FP.screen.height * 9 / 10, btnDonePressed, "End", { size: 50, color: 0xFFFFFF } );
btnDone.setCentered(true);
add(btnDone);
}
private function btnDonePressed():void
{
System.exit(0);
fscommand("quit");
}