Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 846
  • Last Modified:

Flash CS5 AS3 Progress bar while loading new video

The following code loads up a new video when the playhead reaches a specific frame.

I want to show a small progress bar and percentage counter in the middle of the stage while the video is loading, then have it disappear when load=complete.

I'm using an FLVPLayer Component and the following code to load each video:

//Change video source
vplayer.source = "texture.f4v";
vidname="texture";
vplayer.seek(0);
vplayer.play();
0
tlengnick
Asked:
tlengnick
1 Solution
 
tlengnickAuthor Commented:
This worked:

//Video Loading Progress Checker
vplayer.addEventListener(ProgressEvent.PROGRESS, onLoadProgress);
function onLoadProgress(event:ProgressEvent):void
{
      loader_txt.visible = true;
      var total:Number = event.bytesTotal;
      var loaded:Number = event.bytesLoaded;
      bar_mc_i.scaleX = loaded/total;
      loader_txt.text = Math.floor((loaded/total)*100) + "%";

    if (total==loaded)
      {
       vplayer.seek(0);
         vplayer.play();
         vplayer.removeEventListener(ProgressEvent.PROGRESS, onLoadProgress);
         bar_mc_i.visible = false;
         loader_txt.visible = false;
    }
 }
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now