如何检查如果SWF已在AS3被聚焦(How to check if the swf has been

2019-07-31 12:48发布

我只是认为这将是有益知道如何检查,如果主权财富基金已经集中或以其他方式。 当最终用户点击阶段的外侧(在浏览器的地址栏,例如)出现这种情况。

Answer 1:

stage.addEventListener(Event.DEACTIVATE, notFocused);
stage.addEventListener(Event.ACTIVATE, focused);
function notFocused(e:Event) {
    trace("Not focused");
}
function focused(e:Event) {
    trace("Focused");
} 


Answer 2:

我们也可以利用NativeApplication在AIR应用程序相同。

import flash.desktop.NativeApplication;
import flash.events.Event;

NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, onActivate);
NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, onDeactivate);

function onActivate(e:Event){
        trace("Activate");
}

function onDeactivate(e:Event){
    trace("Deactivate");
}


文章来源: How to check if the swf has been unfocused in AS3