Flash CS5 AS3 Progress bar while loading new video

Posted on 2012-09-09
Last Modified: 2012-09-19
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";
Question by:tlengnick
    1 Comment

    Accepted Solution

    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.removeEventListener(ProgressEvent.PROGRESS, onLoadProgress);
             bar_mc_i.visible = false;
             loader_txt.visible = false;

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
    In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
    In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
    The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now