I am trying to pass variables from key frames to my document class but I am not having much success. This is my package which starts by playing a voice over and when the voice over is done, it moves to the next frame in the movie.
package {
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.media.*;
import flash.events.*;
public class PlayVoiceOvers extends MovieClip {
private var VSound:Sound = new Sound();
private var channel:SoundChannel = new SoundChannel();
private var voiceToPlay:String="Voices/v001.mp3";
private var frameToPlay:String="v2";
private var req:URLRequest=new URLRequest(voiceToPlay);
private var context:SoundLoaderContext=new SoundLoaderContext(500,true);
private var newreq:URLRequest = new URLRequest(voiceToPlay);
public function PlayVoiceOvers() {
trace(voiceToPlay);
VSound.load(req, context);
channel=VSound.play();
channel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler, false, 0, true);
}
public function soundCompleteHandler(event:Event):void {
//trace(frameToPlay);//"v2"
gotoAndPlay(frameToPlay);
trace(voiceToPlay);
trace(frameToPlay);
PlayMyNextSound();
}
public function PlayMyNextSound(){
newreq=new URLRequest(voiceToPlay)
VSound.load(newreq, context);
channel=VSound.play();
channel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler, false, 0, true);;
}
}
}
On the next frame of the movie I have this code. The idea is that once the voice over is done playing it advances to the next frame but it doesn’t appear to be working. What am I doing wrong?
stop();
voiceToPlay = "Voices/v002.mp3";
frameToPlay = "v3";
I get this error:
Error: Error #2037: Functions called in incorrect sequence, or earlier call was unsuccessful.
at flash.media::Sound/_load()
at flash.media::Sound/load()
at PlayVoiceOvers/PlayMyNextSound()
at PlayVoiceOvers/soundCompleteHandler()