views:

216

answers:

3

Is there a shortcut for closing Flash Player in Flash? It frustrates me to the death when I have to click every time

A: 

Well the short answer is no there is no direct shortcut.

The longer answer is you could just use ctr-Enter to test and ctr-w to close (Ctr-W closes flash players window). Because control enter makes the test front and it focus's on it that could work.

command+Enter and Command+w for Macs.

This should be fine on a decent machine with smaller projects, where you are testing things quickly.

Hope that helps!

Bryan Hare
It closes the Flash Player window, but it doesen't return the focus to Actions - Frame. Even when coding in FlashDevelop as AS project I have to move my hand from a Keyboard to mouse.
dd
A: 

Flash Player 9.0.115.0 adds flash.system.System.exit ... so you can listen on any custom input event and close it, in case you are using AS3 and the according player ...

back2dos
A: 

Sorry back2dos, but flash.system.System.exit only works in AIR. In a browser it throws, indicating "exit only available in standalone". If you want to plain-old exit, close the browser window.

But you can get very clever in order to do more...

I had a situation where I wanted to exit the Flash app and return to the same page where the Javascript would then do some work and possibly relaunch a Flash app. To do this, create a javascript function in your index template that you can call from Flash.

The args (any number of args) can be anything you want to pass, but the bottom line is that the Javascript will relaunch the same page but pass parameters to it like this:

Add to your index template html:

 function relaunch(arg1, arg2){
    window.onbeforeunload = allowClose;
    var url = assembleUrl(document.URL, arg1);
    url = assembleUrl(url, arg2);
    window.open(url, "_self", "", true);
 }
 function allowClose(){}                   

Okay, you probably have a couple more questions now.

First of all, assembleUrl() is a javascript function you write to append the arguments to your url as you see fit. After all, you will be writing the html/javascript that reads and processes those args.

Secondly, the allowClose() stuff eliminates the user confirmation on exit from your Flash app. Note that the braces have nothing between them - an important quirk.

How do you call this from Flash?

 flash.external.ExternalInterface.call("relaunch", arg1, arg2);   

And it works like a charm, not only in older Flash, but in FB4/Flash10/Spark as well.

Good luck, jim

Jim Clack