Description
Hi,
My apologies for the code - I've found some preload, onload and onsoundcomplete script and welded it together in my garage with a blowtorch and hammer but it doesn't work - I'ts just gobbledegook to me!
I'm trying to get movie2 to play when an external mp3 has loaded. When the mp3 has finished I then want to go back to playing movie1. This is the code that I've murdered: (it sort of works but there's a glytch with the sound as the movie2 starts to play and then if the sound has not fully loaded movie2 continues to play but without sound).
function loadSpeech()
{
var url:String = "character/english/nick_2_" + speechNumber + ".mp3";
// Create a new Sound object to play the sound.
var my_sound:Sound = new Sound();
//preload
function checkProgress(soundObj:Object):Void
{
var numBytesLoaded:Number = soundObj.getBytesLoaded();
var numBytesTotal:Number = soundObj.getBytesTotal();
var numPercentLoaded:Number = Math.floor(numBytesLoaded / numBytesTotal * 100);
if (!isNaN(numPercentLoaded))
{
trace(numPercentLoaded + "% loaded.");
}
}
my_sound.onLoad = function():Void
{
trace("load complete");
clearInterval(poll);
};
//End of preload
my_sound.loadSound(url,true);
var poll:Number = setInterval(checkProgress, 100, my_sound);
my_sound.onLoad = function(success:Boolean)
{
if (success)
{
my_sound.start();
_level2.character.gotoAndPlay(characterAttitude);
_level2.character.timer.gotoAndPlay("active");
}
};