1 Reply Latest reply on Jun 13, 2010 8:59 PM by tunghoy

    Preloader with a movie clip


      Hello there,

      I know this is a newby question, your patience is appreciated.  I've been fiddling with this setup for too long.


      I'm trying to setup the most basic preloader, just the word "Loading..." while my swf file loads at the top of my website.


      I learned an example of this method on lynda.com but it doesn't seem to work right with my little movie.  I made this swf file in

      After Effects, when I imported it into Flash it automatically broke the swf content into 240 bitmap frames and assigned them to

      frames 1-240 (at 24 fps), and did not lay the sound into the timeline.  So I tried to shift the whole movie to frames 2-241

      and put my preloader on frame1, set it up with its own layer with the following action script:


      onClipEvent (enterFrame) {
          if (_parent.getBytesLoaded() == _parent.getBytesTotal()) {


      On frame 2, the preloader hits a blank keyframe and goes away, it's supposed to check the progress of file loading, hold the animation,

      then run the animation when loaded.  This didn't work too well.  I couldn't help but figure that once the first bitmap (frame 2) loaded, it

      was satisfied and then launched the movie early, so I figured I needed to import the bitmap sequence into its own symbol movie clip so

      it will all load at one time into frame 2. I added the original audio into this movie clip too, set it up to stop() on the last frame.


      I was able to do this - so my _parent level scene 1 has 2 frames, frame 1  plays the preloader, frame 2 is supposed to load and play the entire movie clip once it has been given permission to advance.

      Instead, I get this looping audio echo and the movie doesn't show up.


      There has to be a simple way to do this - it's used all the time. I thought about bringing in the movie as a quicktime, but the compression does not

      look good.

      Any detailed help with specific info would be greatly appreciated - I may not be able to do anything with some quick, general info.


        • 1. Re: Preloader with a movie clip
          tunghoy Level 1

          You're trying to do this in a way that's more complicated than is necessary, IMO. I think it's easier to create the preloader in the main timeline, and also easier to use ActionScript 3 instead of 2. Try this:


          1. Create 2 layers. Call them Preloader Content and Preloader Actions. Don't put anything else in frame 1 of the timeline except what goes in these two layers. These layers should have a keyframe in frame 1 and have no frames beyond frame 1.
          2. Make the content of your movie start on frame 3.
          3. In frame 1 of the Preloader Content layer, draw a long rectangle with a stroke. That will be a progress bar. You can leave the stroke as an unnamed shape, but convert the fill to a movie clip symbol. Give it an instance name of progressbar_mc.
          4. Above or below the progress bar, draw a dynamic text box. That will display a changing percentage of how much data are being loaded. Give the text box an instance name of progress_txt and format it however you want the text to look.
          5. In frame 1 of the Preloader Actions layer, insert the AS3 code below:




          this.addEventListener(Event.ENTER_FRAME, loading);


          function loading(e:Event):void {

          var total:Number = this.stage.loaderInfo.bytesTotal;

          var loaded:Number = this.stage.loaderInfo.bytesLoaded;


          progressbar_mc.scaleX = loaded/total;

          progress_txt.text = Math.floor((loaded/total)*100)+ "%";


          if (total == loaded) {


          this.removeEventListener(Event.ENTER_FRAME, loading);