Skip navigation
PeterW-cs
Currently Being Moderated

Actionscript 3.0 Download progress bar for streaming audio not working

Jun 24, 2012 10:01 PM

This is my first ever post here. 

 

The bad script is below.  The movie has 1 frame.  When simulating a download, (DSL speed, 3MB .mp3) nothing displays on the stage until the entire .mp3 has completed downloading.

At this point all the trace statement outputs (1%, 2,3...100%)  rapidly appear in the Output panel, (if I use an event progress COMPLETED handler it traces out loaded at this point) ,

the graphics then appear on stage and the progress bar is set at 100% and the sound starts playing.

 

It looks like it downloads the .mp3, suspending other processing as it does but queues up the progress event outputs, then rushes through all the Progress Events outputs in 1 burst,

reports load completed (if a handler is included for this), displays graphics and then plays audio. It is not streaming.

 

I want to see the progress bar gradually climb up to 100% with text updates as it plays streaming.

 

I have tried using other events such as a Timer or Enter Frame. No go. Nothing displays until the .mp3 has completely downloaded.

Is this a known AS 3.0 bug?  I have found nothing on the web about this issue.

 

I have lost all my hair on this one.  (Note: Actionscript two version works fine.)

A guru will solve this.

 

stop();

 

var theSound:Sound= new Sound();

theSound.load(new URLRequest("c2.mp3"));

var channel:SoundChannel;

channel=theSound.play();

 

theSound.addEventListener(ProgressEvent.PROGRESS, showStreaming);

 

function showStreaming(event: ProgressEvent):void {

    var loaded:Number=event.bytesLoaded;

    var total:Number=event.bytesTotal;

    var loadPercent:Number=Math.round(loaded/total*100);

    trace(loadPercent);

 

    progressBar_mc.scaleX=loadPercent/100;

    percent_txt.text="Downloaded "+loadPercent+"%";

} //showStreaming;

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points