« Good news for RIA and SWF | Main | Merapi is now available for download »
Flex Applications that Warn on Close
| By Rich Tretola | July 2, 2008 | Print This Post
|
| 203 views |
Occasionally, there are times when you need to give the user the heads up that closing the application could cause issues as there are processes currently running.
This example shows an easy way to do this via the FABridge. Click the link below to run the sample.
So, how does it work?
Here are the steps to take to add this functionality.
- <bridge:FABridge bridgeName="flex"/>
- public var warnUser:Boolean;
- public var warningMessage:String;
- window.onbeforeunload = confirmExit;
- function confirmExit()
- {
- var flexApp = FABridge.flex.root();
- if(flexApp.getWarnUser())
- {
- return flexApp.getWarningMessage();
- }
- }
- <!-- BEGIN Warn on Close -->
- <script src="bridge/FABridge.js" language="javascript"></script>
- <script src="bridge/WarningBridge.js" language="javascript"></script>
- <!-- END Warn on Close -->
That’s it. To avoid security sandbox errors, just make sure you run the sample through a web server and not a file path. Here is the full source code.
Topics: Flex 3 (Moxie) |









July 2nd, 2008 at 9:20 am
Thanks but It doesn’t work neither on Safari 3.1 (Mac) nor on Opera 9.5(Mac)
July 2nd, 2008 at 10:11 am
Fantasic, thanks!
Just the thing I needed
July 2nd, 2008 at 11:30 am
Hm, you are right, I tried it in Safari 3.1 and it doesn’t work. I am not sure why.