0 Replies Latest reply on Nov 4, 2007 10:56 AM by damonlee

    Here is a Simple AS3 Preloader

      I've seen many overly complicated tutorials on building a AS3 preloader. I'm not sure the reason for all the complexity...maybe alot of developers feel that Every entity must be scripted...

      This guy from newgrounds.com has made a very simple one (Finally, someone with enough sense to make things easy)

      Its easy as 1-2-3 and maybe 4:

      1. create a bar on the stage and give an instance name of lbar
      2. create a dynamic text field and give instance name of lbc

      3. Code to insert on frame one of your movie:

      //Import the required assets
      import flash.display.*;
      //Stop the playhead while loading occurs

      //Create a listener to call the loading function as the movie loads
      this.loaderInfo.addEventListener (ProgressEvent.PROGRESS, PL_LOADING);

      /*This is the main function, basically it grabs the total and loaded bytes,
      calculates a percentage, and displays it by stretching the bar and adjusting
      the textfield display. If your bar/textbox instancenames are NOT lbar/lpc,
      you'll need to adjust this code to match your instance names*/
      function PL_LOADING(event:ProgressEvent):void {
      var pcent:Number=event.bytesLoaded/event.bytesTotal*100;
      //Stretch the bar
      //Display the % loaded in textfield
      //If the movie is fully loaded, kick to the next frame on the main timeline
      //You may wish to change the gotoAndStop(2) to a gotoAndPlay(2)

      He has some more info on embedding the fonts and symbols if desired: