Показать сообщение отдельно
Старый 04.07.2007, 22:44
telit вне форума Посмотреть профиль Отправить личное сообщение для telit Найти все сообщения от telit
  № 4  
Ответить с цитированием
telit
 
Аватар для telit

Регистрация: Jul 2007
Сообщений: 306
Код:
package {
    import flash.display.Sprite;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.net.URLRequest;
    import flash.events.Event;

    public class ProgressBar2 extends Sprite {
        private var _sound:Sound;
        private var _channel:SoundChannel;
        
        public function ProgressBar2(  ) {
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
            _sound = new Sound(new URLRequest("http://fla-md.com/play/song1.mp3"));
            _channel = _sound.play(  );
        }
        
        public function onEnterFrame(event:Event):void
        {
            var barWidth:int = 200;
            var barHeight:int = 5;
            
            var loaded:int = _sound.bytesLoaded;
            var total:int = _sound.bytesTotal;
            
            var length:int = _sound.length;
            var position:int = _channel.position;
            
            // Draw a background bar
            graphics.clear(  );
            graphics.beginFill(0xFFFFFF);
            graphics.drawRect(10, 10, barWidth, barHeight);
            graphics.endFill(  );

            if(total > 0) {
                // The percent of the sound that has loaded
                var percentBuffered:Number = loaded / total;

                // Draw a bar that represents the percent of 
                // the sound that has loaded
                graphics.beginFill(0xCCCCCC);
                graphics.drawRect(10, 10, 
                                  barWidth * percentBuffered,
                                  barHeight);
                graphics.endFill(  );
                
                // Correct the sound length calculation
                length /= percentBuffered;
                
                  // The percent of the sound that has played
                  var percentPlayed:Number = position / length;

                // Draw a bar that represents the percent of 
                // the sound that has played
                graphics.beginFill(0x666666);
                graphics.drawRect(10, 10, 
                                  barWidth * percentPlayed,
                                  barHeight);
                graphics.endFill(  );
            }
        }
    }    
}
вот показывает текущую позицию песни