检测从adobe air app切换到另一个窗口

时间:2011-07-18 21:30:11

标签: flash flex adobe air

我如何确定是否有人切换到另一个窗口(比如记事本),同时保持空中应用程序打开,我正在寻找一种方法来检测用户是否将空中应用程序切换到另一个。

1 个答案:

答案 0 :(得分:0)

查看激活和停用事件处理程序:

<?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>