How can I determin开发者_开发知识库e if someone switch to another window (say notepad) while keeping air app open behind, I was looking for a way to detect if user switch form air app to another.
Check out the activate and deactivate event handlers :
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
deactivate="deactivateHandler(event)"
activate="activateHandler(event)"
>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
protected function deactivateHandler(event:Event):void
{
mx.controls.Alert.show('you left!');
}
protected function activateHandler(event:Event):void
{
mx.controls.Alert.show('you came back!');
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
精彩评论