1

我有这个循环播放的 flv 视频,并且我有一个在电影运行时播放的随机电影。我需要在播放另一部电影时将shaker其禁用或停止该随机循环。谢谢

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:MouseEvent){

    ns.play("video_3.flv");
    loader.button_01_mc.gotoAndPlay (41);
4

1 回答 1

1

试试这个:将计时器向上移出功能。调用所需函数中的停止。

更新 1:恢复对计时器所做的更改并添加单次播放功能,以便只播放一个动画。(不循环播放动画,只是随机播放一个。)

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);
var refCurrentAnimation:MovieClip;

function playClips(event:TimerEvent):void{

    if(!refCurrentAnimation)
    {
        var i:Number=Math.floor(Math.random() * mcArray.length);
        var movieClipToEdit:MovieClip=mcArray[i] as MovieClip;
        movieClipToEdit.gotoAndPlay (1);
        refCurrentAnimation = movieClipToEdit;
        clipTimer.stop();
    }
}
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:MouseEvent){

    ns.play("video_3.flv");
    loader.button_01_mc.gotoAndPlay (41);
}
于 2013-02-04T10:07:23.793 回答