Skip navigation
dchero
Currently Being Moderated

Preloader for multiple scenes

Jun 19, 2012 4:28 AM

Hi, I'm trying to make a web site, I have 7 scenes and everything is working perfect. But here's my question.

When I try to make 1st scene as a preloader nothing happens. Preloader never shows up and it jumps directly to 2nd scene "Main"

Here's my code:

 

stop();

 

 

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;

 

 

          bar_mc.scaleX = loaded/total;

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

 

 

          if (total == loaded) {

                    gotoAndPlay(1,"Main");

                    this.removeEventListener(Event.ENTER_FRAME, loading);

          }

 

 

}

 

Also if I delete my contents in the "Main" scene and leave a single image, code works perfect.

Preloader shows up and then loads my "Main" scene.

How can I code it, as it first calculates my whole scenes, and shows my 1st scene "preloader" at the beginning.

 
Replies
  • Currently Being Moderated
    Jun 19, 2012 4:57 AM   in reply to dchero

    You should try creating the preloader as a separate file and load your web site file into that.  Here is a link to a tutorial....

     

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

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2012 7:42 AM   in reply to dchero

    What are the complete error messages?

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2012 7:51 AM   in reply to dchero

    Those two lines have periods where there should be commas...

     

         ...(ProgressEvent.PROGRESS, loop);

         ...(Event.COMPLETE, done);

    
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 19, 2012 1:21 PM   in reply to dchero

    You're welcome

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points