标签:rev obj pac load extends 错误 attach mouse oid
package com{ import flash.display.MovieClip; import flash.net.NetConnection; import flash.net.NetStream; import flash.events.AsyncErrorEvent; import flash.events.MouseEvent; import flash.media.Video; import flash.display.SimpleButton; import flash.events.Event; import flash.display.Loader; import flash.net.URLLoader; import flash.net.URLRequest; import flash.utils.Timer; import flash.events.TimerEvent; public class MyLoader extends MovieClip { public static var nc:NetConnection; public static var ns:NetStream; public static var vid:Video; public static var empty:MovieClip; public static var vidTotalTime:Number; public static var vidNowTime:Number; public static var obj:Object=new Object ; public static var loader:Loader; public static var urlR:URLRequest; public static var backBtn:SimpleButton; public static var removeBoo:Boolean=false; public static var timer:Timer; public static var btnMc:MovieClip; public static var picMc:MovieClip; private var vidY:Number private var initX:Number private var vidW:Number private var vidH:Number private var interval:Number //加载视频============================================ public function MyLoader(_empty:MovieClip,_btnMc:MovieClip,_picMc:MovieClip) { empty=_empty; btnMc=_btnMc; picMc=_picMc vidY=picMc.y initX=picMc.x vidW=picMc.width vidH=picMc.height interval=212.45 btnMc.addEventListener(MouseEvent.MOUSE_MOVE,btnFun); nc=new NetConnection ; nc.connect(null); ns=new NetStream(nc); ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR,asyncErrorHandler); ns.close(); vid=new Video(vidW,vidH); function asyncErrorHandler(event:AsyncErrorEvent):void { // 忽略错误 } obj.onMetaData=onMetaData; ns.client=obj; function onMetaData(data:Object):void { vidTotalTime=data.duration; } //ns.play("vid/"+2+".mp4"); //empty.addChild(vid); vid.attachNetStream(ns); ns.pause(); vid.smoothing=true; timer=new Timer(25); timer.addEventListener(TimerEvent.TIMER,timerFun); } //播放暂停 public static function togglePauseFun() { ns.togglePause(); } public static function removeMP4() { if (ns.time!=0) { ns.close(); empty.removeChild(vid); } } public static function addMP4(str:String) { while (empty.numChildren<0) { empty.removeChildAt(0); } ns.play(str); empty.addChild(vid); ns.pause(); } public static function timerFun(e:TimerEvent) { vidNowTime=ns.time; if ((vidTotalTime-vidNowTime)<0.1) { ns.close(); empty.removeChild(vid); timer.stop(); for (var i:uint=1; i<=5; i++) { btnMc["btn_"+i].visible=true; } } } private function btnFun(e:MouseEvent) { if (timer.running==false) { timer.start(); empty.addChild(vid); } var str:Number=Number(e.target.name.slice(-1)); ns.play(("vid/"+str)+".mp4"); vid.y=vidY vid.x=initX+(vid.width+interval)*(str-1) for (var i:uint=1; i<=5; i++) { if (str==i) { btnMc["btn_"+i].visible=false; } else { btnMc["btn_"+i].visible=true; } } } } }
标签:rev obj pac load extends 错误 attach mouse oid
原文地址:https://www.cnblogs.com/zqiang0803/p/9246368.html