您好我有一个NetStatusEvent
,我正在播放视频,而且我正在播放audio
。在同一时间。两者都在循环。如您所见,我已将sound.play
放入NetStatusEvent
函数中。而现在,每当我的视频循环播放新的音频时,它就会变得非常混乱。所以我的问题是如何在两个函数中执行此操作。谢谢。
import flash.events.MouseEvent
import flash.events.Event;
import flash.media.Sound;
import flash.media.SoundLoaderContext;
import flash.net.URLRequest;
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("http://media.easyads.bg/ads/display_ads_richmedia/video/avon/maria_ilieva/video_1.flv");
ns.addEventListener(NetStatusEvent.NET_STATUS, NCListener);
var clipTimer:Timer = new Timer(4000);
function NCListener(e:NetStatusEvent){
if (e.info.code == "NetStream.Play.Stop") {
ns.play("http://media.easyads.bg/ads/display_ads_richmedia/video/avon/maria_ilieva/video_2.flv");
sound.load(new URLRequest("sound.mp3"));
}
};
var sound:Sound = new Sound();
var soundChannel:SoundChannel= new SoundChannel();
sound.addEventListener(Event.COMPLETE, onSoundLoadComplete );
function onSoundLoadComplete(e:Event):void{
sound.removeEventListener(Event.COMPLETE, onSoundLoadComplete);
soundChannel = sound.play(0, 9999);
soundChannel.addEventListener(Event.SOUND_COMPLETE, onSoundChannelSoundComplete);
}
function onSoundChannelSoundComplete(e:Event):void{
e.currentTarget.removeEventListener(Event.SOUND_COMPLETE, onSoundChannelSoundComplete);
soundChannel = sound.play(0, 9999);
}
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){
clipTimer.stop();
ns.play("http://media.easyads.bg/ads/display_ads_richmedia/video/avon/maria_ilieva/video_3.flv");
loader.button_01_mc.gotoAndPlay (41);
soundChannel.stop();
}
function play_effect_01 (event:Event):void{
loader.button_01_mc.gotoAndPlay (2);
}
loader.button_02.addEventListener(MouseEvent.CLICK, play_video_02);
loader.button_02.removeEventListener(TimerEvent.TIMER, play_video_02);
loader.button_02.addEventListener(MouseEvent.ROLL_OVER, play_effect_02);
function play_video_02 (event:Event):void{
clipTimer.stop();
ns.play("http://media.easyads.bg/ads/display_ads_richmedia/video/avon/maria_ilieva/video_4.flv");
loader.button_02_mc.gotoAndPlay (42);
soundChannel.stop();
}
function play_effect_02 (event:Event):void{
loader.button_02_mc.gotoAndPlay (2);
}
loader.button_03.addEventListener(MouseEvent.CLICK, play_video_03);
loader.button_03.removeEventListener(TimerEvent.TIMER, play_video_03);
loader.button_03.addEventListener(MouseEvent.ROLL_OVER, play_effect_03);
function play_video_03 (event:Event):void{
clipTimer.stop();
ns.play("http://media.easyads.bg/ads/display_ads_richmedia/video/avon/maria_ilieva/video_5.flv");
loader.button_03_mc.gotoAndPlay (45);
soundChannel.stop();
}