至少有两种选择:
1:将进度条保持在 0%,在声音完全加载之前不要移动它。那是:
sound.addEventListener(Event.COMPLETE, onSoundComplete);
private function onSoundComplete(event:Event):void {
// Calculate progress
}
2:基于已加载文件百分比的近似百分比。像这样的东西:
private var _sound:Sound = /* Your logic here */;
private var _channel:SoundChannel = _sound.play();
_sound.addEventListener(ProgressEvent.PROGRESS, onSoundProgress);
private function onSoundProgress(event:ProgressEvent):void {
var percentLoaded:Number = event.bytesLoaded / event.bytesTotal;
var approxProgress:Number
= _channel.position / _sound.length * percentLoaded;
// Update your progress bar based on approxProgress
}