2013-02-04 123 views
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); 

回答

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); 
} 
+0

它的工作就是這樣。但是,當我播放video_3.flv並等待它結束時啓動video_2.flv。當video_2.flv播放時,有2個隨機的電影剪輯從'mcArray'播放。在另一個週期後,有3個電影剪輯播放? – Kircho

+0

,你想要停止?或只有一個人玩?讓它停止你所要做的就是:把clipTimer.stop();在ns.play(「video_2.flv」)之前;在相同的功能裏面。要獲得只有一個播放:你想創建一個var refCurrent:MovieClip之外的playClips函數和內部檢查,看看refCurrent.currentFrame == refCurrent.totalFrames之前告訴新的movieClipToEdit播放和不要忘記存儲refCurrent聲明中的movieClipToEdit。 – bnns

+0

我只需要一個人玩。你可以把它作爲代碼請給它。謝謝。 – Kircho