4 Replies Latest reply on Jun 13, 2006 7:47 PM by Steven_Lyons

    not another preloader question!

    hushhurt Level 1
      ok - i created a pre-loader movie that has 100 frame animation with a stop action on frame one.

      I placed the MC on the main timeline and named it: lineLoader_mc

      then placed the following code:

      lineLoader_mc.onEnterFrame = function () {
      framesLoaded = Math.round ((_root._framesloaded / _root._totalframes) * 100);
      this.gotoAndStop (framesLoaded);
      this.info.text = framesLoaded + "% completed";
      if (framesLoaded >= 100) {
      _root.gotoAndPlay("start");
      }
      };

      when i test the movie, it doesn't sow the preloader at first, then it quickly jumps to 91% completed, loads a little more - then plays the main timeline.

      what am i doing wrong?

      thanks,

      david
        • 1. not another preloader question!
          Webmaster_Pete Level 1
          David,
          I'm not sure if this is the issue. I would need to see your fla, but it sounds like flash is downloading other content for you movie before it downloads the preloader movie clip. Also preloading via frames isn't used much anymore unless there is a specific reason you need to do it. Preloaders should be the only content on the screen for your movie. Thus you want to use different 'Scenes' to really make sure your preloader is downloaded first.

          Solution: Unless you are on an older version of flash I recommend you do the following (note: I'm on a Mac - Flash 8):

          Part 1) In flash click on the menu 'Window->Other Panels->Scene' this should bring up your scene window. You should have one scene in it already named 'Scene 1'. Change the name of this scene to 'Main'. Then click on the '+' icon to add a new scene and name this 'Loading'. Make sure 'Loading' is set as the first/top scene in the list.

          Part 2) Click on 'Loading' to bring it up in the stage editor. Now create a layer called 'Actions' and another one called 'Text'. In this layer make the first three frames each their own keyframe. The 'Text' layer should just be one keyframe across all the frames.

          Part 3) In the first frame of the 'Actions' layer paste this code:
          if (_framesloaded>=_totalframes) {
          this.info.text = "100% completed";
          gotoAndPlay(3);
          } else {
          this.info.text = Math.round((getBytesLoaded()/getBytesTotal()*100)) + "% completed";
          }

          In the second frame of the 'Actions' layer put this:
          gotoAndPlay(1); // Loops the movie until its downloaded

          In the third frame put this:
          nextScene(); // Once all the frames are loaded it proceeds to the next frame

          Part 4) Now in the 'Text' layer place your textbox. In your 'Main' scene with all your content you can remove your preloader movie from the timeline. You don't need it there anymore.


          Run the movie and you should see a more accurate preloader. Also you movie could just be small enough that it does download quickly. Another bit of advice is when your compile your flash movie by 'cmd + enter' you can goto 'View->Bandwidth Profiler' this will let you see which parts of your movie are downloaded and how much is downloaded for each part. You can also emulate different connection speeds via the same 'View' menu.

          Next lession putting it all in one frame and use the interval function but I won't go into that here.

          Hope this helps.
          • 2. Re: not another preloader question!
            hushhurt Level 1
            thanks pete,

            but i have a tween animation (frames 1-100) for the pre-loader, how could i use the scene pre-loader with the tween.

            also, regarding - loading jpgs dynamically, the scene pre-loader won't work with loading the jpgs, will it?
            • 3. not another preloader question!
              Steven_Lyons Level 1
              This question has been asked a thousand times before.

              Forget Scenes.

              1. Put your 100 frame preloader animation inside a MovieClip. Give it an instance name of "preloader".
              2. Put your preloader MovieClip on Frame 1 and everything else on Frame 2.

              Actionscript for frame 1 (preload frame):
              • 4. Re: not another preloader question!
                Steven_Lyons Level 1
                Preloading .jpg's is handled completely differently. Look up MovieClipLoader in the Flash help files and you will see examples there.