Activate、Deactivate 事件 Activate ThrottleEvent;

http://help.adobe.com/zh_CN/as3/mobile/WS4bebcd66a74275c36cfb8137124318eebc6-8000.html
 
Activate、Deactivate 事件
Activate -当一个对象成为活动窗口时发生。
Deactivate -当一个对象不再是活动窗口时发生。

ThrottleEvent;    注: 暂停、节流和恢复功能不适用于 Adobe® AIR® 应用程序。

对于运行在 Windows 和 Mac 台式机浏览器上的 Flash Player 11.2 和更高版本,可以在应用程序中使用 ThrottleEvent。Flash Player 暂停、节流或恢复播放时调度 ThrottleEvent。

此 ThrottleEvent 事件为广播事件,这意味着将由所有具有注册了此事件的侦听器的 EventDispatcher 对象调度此事件。

很简单.就是当swf为顶层应用时..则触发Activate事件..否则不是..

用法...

第一种:

NativeApplication 类表示此 AIR 应用程序。位于flash.desktop包中..只属于air运行时

NativeApplication 类提供应用程序信息、应用程序范围内的函数,并调度应用程序级别的事件。

NativeApplication 对象是一个在启动时自动创建的单一对象。使用静态属性 NativeApplication.nativeApplication 获取应用程序的 NativeApplication 实例。

            NativeApplication.nativeApplication.addEventListener(

                flash.events.Event.ACTIVATE, function (e:*):void { mStarling.start(); });

            

            NativeApplication.nativeApplication.addEventListener(

                flash.events.Event.DEACTIVATE, function (e:*):void { mStarling.stop(true); });

 

第二种: 添加到舞台上

	
this.stage.addEventListener(Event.DEACTIVATE, stage_deactivateHandler, false, 0, true);

	private function stage_deactivateHandler(event:Event):void
		{
			trace("非活动");
			
			this._starling.stop();
			this.stage.addEventListener(Event.ACTIVATE, stage_activateHandler, false, 0, true);
		}

		private function stage_activateHandler(event:Event):void
		{
			
			trace("活动");
			this.stage.removeEventListener(Event.ACTIVATE, stage_activateHandler);
			this._starling.start();
		}

  

原文地址:https://www.cnblogs.com/zhepama/p/3359463.html