Created
June 28, 2011 18:31
-
-
Save tpryan/1051820 to your computer and use it in GitHub Desktop.
Mobile Application that closes itself 30 seconds after it loses focus.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" | |
creationComplete="init(event)" | |
xmlns:s="library://ns.adobe.com/flex/spark" > | |
<fx:Script> | |
<![CDATA[ | |
import mx.events.FlexEvent; | |
public var closeTimer:Timer; | |
protected function init(event:FlexEvent):void | |
{ | |
NativeApplication.nativeApplication.addEventListener( | |
Event.DEACTIVATE, onDeactivate); | |
NativeApplication.nativeApplication.addEventListener( | |
Event.ACTIVATE, onActivate); | |
} | |
protected function onDeactivate(event:Event):void | |
{ | |
closeTimer = new Timer(30000,1); | |
closeTimer.addEventListener(TimerEvent.TIMER_COMPLETE, | |
closeApp); | |
closeTimer.start(); | |
} | |
protected function closeApp(event:Event):void{ | |
NativeApplication.nativeApplication.exit(); | |
} | |
protected function onActivate(event:Event):void | |
{ | |
closeTimer = null; | |
} | |
]]> | |
</fx:Script> | |
</s:Application> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment