Sound preloader problem

I want to load a sound and begin playing when enough has buffered to complete it without stuttering. I can get sound.bytesLoaded and sound.bytesTotal, but the sound.length parameter increases as more of the file downloads. How can I figure this out?

try this after 1-2 seconds of loading…


function getTime(s:Sound):Number {
	var kbps:Number = ((s.getBytesLoaded() / 1000) / (s.duration / 1000));
	var subTotal:Number = s.getBytesTotal() / 1000;
	return (subTotal / kbps) / 60;
}

Ahhh… tricky, clever. I like it! Thanks.