This isn’t really a Flashpunk question at all, but more so a very specific general AS3 question.
Is it possible to close the current browser window/tab using AS3?
I’ve tried:
if (Input.pressed(Key.ESCAPE))
{
trace("Shutting down...");
navigateToURL(new URLRequest("javascript:window.opener=self;window.close ();"));
System.exit(0);
}
The “System.exit(0);” bit is for testing locally. The navigateToURL is what I read on StackOverflow, but I couldn’t seem to get it to work. It just makes my browser tab start flashing white. Maybe it’s just the browser behaving oddly? (Firefox-Windows?) Does it work for anyone else? Try clicking on the swf anywhere and then pressing Escape.