Hi all
I’m having a real big problem with the Event.SOUND_COMPLETE in Flash.
I have a movie that has a bunch of animations on diferent scenes the problem is that I need my movie to wait for my sound to finish before it goes to the next scene, when I use the sound complete it works fine on the first scene but it won’t go past that.
here are my codes any help is widely appreciated.
scene 1
frame 1
import flash.media.Sound;
import flash.net.URLRequest;
import flash.display.Sprite;
import flash.media.SoundChannel;
import flash.events.Event;
import flash.events.MouseEvent;
autoPlay = true;
var _som1:Sound;
var _channel1:SoundChannel;
var nextsceneSoundloadComplete:Boolean;
var currentSound:String = "sound/ModelosAtomicos/cena1.mp3";
var nextSound:String = "sound/ModelosAtomicos/cena2.mp3"
if (_som1) {
_channel1.stop();
_som1=null;
_channel1=null;
}
_som1 = new Sound();
_som1.addEventListener(Event.COMPLETE,soundloadComplete);
_som1.load(new URLRequest (currentSound));
stop();
function soundloadComplete(e:Event):void{
_channel1 =_som1.play();
dispatchEvent(new Event("volAdj"));
play();
preloadSound();
}
function preloadSound():void{
var _som2:Sound = new Sound();
_som2.addEventListener(Event.COMPLETE,preloadComplete);
_som2.load(new URLRequest (nextSound));
}
function preloadComplete(e:Event):void{
nextsceneSoundloadComplete = true;
dispatchEvent(new Event("soundloadcomplete"));
}
function soundF(e:Event):void{
if(hasEventListener("soundloadComplete")){
removeEventListener("soundloadComplete",soundF);
}
_som1 = new Sound();
_som1.load(new URLRequest(currentSound));
_channel1 =_som1.play();
dispatchEvent(new Event("volAdj"));
play();
if(nextSound){
preloadSound();
nextsceneSoundloadComplete = false;
}
}
scene 1
last frame
stop()
_channel1.addEventListener(Event.SOUND_COMPLETE, somCompleto)
function somCompleto(e){
play()
}
scene 2
frame 1
import flash.events.Event;
currentSound = "sound/ModelosAtomicos/cena2.mp3";
nextSound = "sound/ModelosAtomicos/cena3.mp3"
if (_som1) {
_channel1.stop();
_som1=null;
_channel1=null;
}
stop();
if(nextsceneSoundloadComplete){
soundF(null);
nextsceneSoundloadComplete = false;
} else {
addEventListener("soundloadComplete",soundF);
}
scene 2
last frame
stop()
_channel1.addEventListener(Event.SOUND_COMPLETE, somCompleto)
thanks in advance…
And please be clear on your anwsers because I’m not that much of a programer.