View Full Version : [AS2] Projector on quit function
littleguy835
03-24-2009, 06:27 AM
I've scowered the internet looking for an answer for this problem, but have been unsuccessful.
Is there a way to run a script when the user quits or closes a flash Projector?
An example would be if someone just clicked the build in close button, can I catch it, and run a script before if actually quits? Here's an image of what I'm talking about:
32050(Mac) or 32051(Win)
If the user quit the projector by clicking those close buttons.
I'm making an application in flash, and would like to prompt the user to save their changes when they close out the application.
Any assistance would be great! Thanks! :)
MonsterOverTheHill
03-24-2009, 10:52 AM
Perhaps you could create a quit button and then do some thing like:
quit_btn.onRelease = function() {
...extra actions here
fscommand("Quit", "");
}
littleguy835
03-24-2009, 03:04 PM
Thanks MosterOverTheHill for the quick reply.
I'm aware of that method, and will use that if I don't find what I'm looking for. But I'm wondering if there's a way to catch if they click the built in quit button, not one I create myself.
:)
MonsterOverTheHill
03-25-2009, 11:38 AM
My only suggestion would be to run it full screen thus hiding the close button.
See this thread:
http://www.actionscript.org/forums/showthread.php3?t=118693
northcode
03-25-2009, 03:50 PM
You can do it, but not with a standard Flash projector, you're going to need a third party swf2exe application to extend the functionality of your Flash application.
I make one of those swf2exe applications, it's called SWF Studio (http://www.northcode.com/swfstudio.php). We have an ActionScript API that allwos you to add on onQuit handler (and a lot more).
// set up the onQuit handler
ssCore.App.setNotify({event:"onQuit"}, {callback:onQuitHandler});
function isOkayToShutdown()
{
// your application decides if/when it's okay
// for the user to quit the application
return true;
}
function onQuitHandler(ret_obj, cb_obj, err_obj)
{
if (ret_obj.success)
{
if (isOkayToShutdown() == true)
{
// perform shutdown task(s) here before closing the application
ssCore.App.forceQuit();
}
else
{
// let the user know we don't want them to quit yet
ssCore.App.showMsgBox({prompt:"Sorry, you can't quit right now"});
}
}
}
This is how you could set up an onQuit event handler using SWF Studio.
1. open a new FLA (let's call it quitter.fla)
2. drop the code above into the new quitter.fla file
3. publish quitter.fla to quitter.swf
4. open SWF Studio (use FREE trial version (http://www.northcode.com/go?id=v3downloads.v3trial.exe))
5. drag and drop quitter.swf onto the SWF Studio window
6. click on the Build button (to create quitter.exe)
7. run quitter.exe and enjoy :)
See also Building your First Application (http://www.northcode.com/v3/help/index.html?page=Getting%20Started_Building%20Your% 20First%20Application.html) for more details on steps 4 through 7.
There are other tools out there that have similar capabilities. If you want to check them out here are some links...
SWF Studio http://www.northcode.com (my baby)
mProjector http://www.screentime.com
SWFKit http://www.swfkit.com
SWiSH Studio http://www.swishzone.com
Jugglor http://www.jugglor.com
Zinc http://www.multidmedia.com
I would caution you to spend some time reading their community forums before you decide on any tool. Find out what kinds of problems real users are having with the tool, getting support etc. That stuff REALLY matters when it's crunch time.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.