禁用功能或删除侦听器as3

时间:2013-02-03 18:36:56

标签: actionscript-3 function

我有7个flv视频,我正在播放。 01_video是简介,它在swf加载后立即启动。然后完成。 02_video正在启动,此视频正在循环直到用户做出选择。通过02_video播放我正在调用一个函数shaker,我只需要在播放02_video时播放。所以我需要当用户点击某些按钮(这将启动其他一些视频)shaker禁用时。我只推了function play_video_01还有4个,它们是相同的。

var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(nc);
loader.vid.Video_1.attachNetStream(ns);


var listener:Object = new Object();
listener.onMetaData = function(evt:Object):void {};
ns.client = listener;

ns.play("video_1.flv");

ns.addEventListener(NetStatusEvent.NET_STATUS, NCListener);

function NCListener(e:NetStatusEvent){
if (e.info.code == "NetStream.Play.Stop") {
ns.play("video_2.flv");
shaker(null);
}
};
addEventListener(Event.COMPLETE,shaker);
function shaker (event:Event):void{

var mcArray:Array = [loader.button_01_mc,loader.button_02_mc,loader.button_03_mc,loader.button_04_mc,loader.button_05_mc];
var clipTimer:Timer = new Timer(4000);

clipTimer.addEventListener(TimerEvent.TIMER, playClips);

function playClips(event:TimerEvent):void{

    var i:Number=Math.floor(Math.random() * mcArray.length);
    var movieClipToEdit:MovieClip=mcArray[i] as MovieClip;
    movieClipToEdit.gotoAndPlay (1);
}
clipTimer.start();
}

loader.button_01.addEventListener(MouseEvent.CLICK, play_video_01);
loader.button_01.addEventListener(MouseEvent.ROLL_OVER, play_effect_01);

function play_video_01 (event:Event):void{

    ns.play("video_3.flv");
    loader.button_01_mc.gotoAndPlay (41);
    this.removeEventListener(Event.COMPLETE,shaker);

}

0 个答案:

没有答案