宜昌本地软件开发与弱电工程服务商
项目咨询 · 快速响应
您当前的位置: > 博客2 > AS2与AS3技术

[AS3]as3初始化StageVideo事件侦听器

2016-10-13 00:16:48 点击量:7 标签: 收藏本文

在应用程序初始化过程中设置 StageVideoAvailabilityEvent 和 VideoEvent 侦听器。例如,可以在 flash.events.Event.ADDED_TO_STAGE 事件处理函数中初始化这些侦听器。此事件可保证您的应用程序在舞台上可见;

  1. public class SimpleStageVideo extends Sprite  
  2.     private var nc:NetConnection;  
  3.     private var ns:NetStream;  
  4.   
  5.     public function SimpleStageVideo()  
  6.     {  
  7.         // Constructor for SimpleStageVideo class  
  8.         // Make sure the app is visible and stage available  
  9.         addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);  
  10.     }  
  11.       
  12.     private function onAddedToStage(event:Event):void  
  13.     {  
  14.         //...  
  15.         // Connections  
  16.         nc = new NetConnection();  
  17.         nc.connect(null);  
  18.         ns = new NetStream(nc);  
  19.         ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);  
  20.         ns.client = this;  
  21.   
  22.         // Screen  
  23.         video = new Video();  
  24.         video.smoothing = true;  
  25.   
  26.         // Video Events  
  27.         // the StageVideoEvent.STAGE_VIDEO_STATE informs you whether  
  28.         // StageVideo is available  
  29.         stage.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY,  
  30.             onStageVideoState);  
  31.         // in case of fallback to Video, listen to the VideoEvent.RENDER_STATE  
  32.         // event to handle resize properly and know about the acceleration mode running  
  33.         video.addEventListener(VideoEvent.RENDER_STATE, videoStateChange);  
  34.         //...  
  35.     } 

 

ABOUT US
宜昌农人网络科技有限公司

我们是一家提供综合软件外包与弱电工程服务的技术公司。

业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。

公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室