Reputation: 827
Need to get sounds duration into memory.
var sound = new Sound(this);
function getSoundDuration(soundName:String):Number
{
var dur = 0;
sound.onLoad = function (success:Boolean) {
if (success) {
dur = this.duration;
}
};
sound.loadSound(soundName, false);
return dur;
}
var DoS1 = getSoundDuration("sound1.mp3");
var DoS2 = getSoundDuration("sound2.mp3");
trace(DoS2);
trace(DoS2);
is that possible without wait onLoad to finish ?
Upvotes: 0
Views: 45
Reputation: 5222
It is not, the sound needs to be loaded in order to read the metadata. If you are using static sound files, you could hard code those values.
Upvotes: 1