3 Replies Latest reply: Aug 2, 2012 4:58 AM by Ned Murphy RSS

    A good simple preloader.

    mentalcase129 Community Member

      I've asked some questions regarding this before on a project I had to put on the backburner.  But I'm back to that project now and am looking at it with new fresh eyes so I thought I'd bring it up again in a new discussion.  I'm working on a Flash website, using Actionscript 3 in Flash cs5.5.  I need a preloader...one that loads and opens a seperate swf.  I got some help putting some code together to make a preloader like this and it works but I'd like to make one more visually pleasing. 

      Can anybody either give me advice or possibly point me towards a tutorial that will teach me to make a preloader with a some sort of loading graphic, like a status bar or something(doesn't have to be anything too crazy) that will load and open another swf?  I've found tutorials in the passed that show how to make status bars and stuff but they're all coded to load another frame within the same swf, which isn't what I want and I don't know my way around as3 well enough to modify it for what I need.

      The key here really is I want it to be simple.  I'm not an actionscript whiz by any stretch. 

      thanks guys!

        • 1. Re: A good simple preloader.
          Ned Murphy MVP

          I believe this meets your requirements, and is a preferred approach...

           

          AS3 Preloader
          -------------

          http://www.gotoandlearn.com/play.php?id=85

          • 2. Re: A good simple preloader.
            mentalcase129 Community Member

            Thanks, this is helpful and will definately do the trick.  I'd love to be able to add a status bar to it though.  Any tips on that?  He alludes to being able to add graphics like that but doesn't elaborate.  My actionscript knowledge is for the most part pretty basic so it's hard to launch into something like that without some guidance.

            • 3. Re: A good simple preloader.
              Ned Murphy MVP

              If you look at the loop function in the code he provides, that is what you will use to control things like a loading bar... the key being to understand and make use of the perc value that is being calculated. 

               

              You can use the perc value to control the scaleX of something, such as a status bar...

               

               

              yourStatusBar.scaleX = 0;  // a starting value for your status bar

               

              function loop(e:ProgressEvent):void

              {

                  var perc:Number = e.bytesLoaded / e.bytesTotal;

                  percent.text = Math.ceil(perc*100).toString();

               

                  yourstatusBar.scaleX = perc;

              }