• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Preloader for multiple scenes

New Here ,
Jun 19, 2012 Jun 19, 2012

Copy link to clipboard

Copied

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.

TOPICS
ActionScript

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jun 19, 2012 Jun 19, 2012

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

     ...(ProgressEvent.PROGRESS, loop);

     ...(Event.COMPLETE, done);

Votes

Translate

Translate
LEGEND ,
Jun 19, 2012 Jun 19, 2012

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 19, 2012 Jun 19, 2012

Copy link to clipboard

Copied

I followed the tutorial, here's the code he suggested.

var l:Loader = new Loader();

l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS. loop);

l.contentLoaderInfo.addEventListener(Event.COMPLETE. done);

l.load(new URLRequest("main.swf"));

function loop(e:ProgressEvent):void

{

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

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

}

function done(e:Event):void

{

          removeChildAt(0);

          percent = null;

          addChild(l);

}

When I try to export this, flash gives me an error with line 2 and line 3.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 19, 2012 Jun 19, 2012

Copy link to clipboard

Copied

What are the complete error messages?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 19, 2012 Jun 19, 2012

Copy link to clipboard

Copied

Scene 1, Layer 'actions', Frame 1, Line 21119: Access of possibly undefined property loop through a reference with static type String.
Scene 1, Layer 'actions', Frame 1, Line 21136: Incorrect number of arguments.  Expected 2.
Scene 1, Layer 'actions', Frame 1, Line 31119: Access of possibly undefined property done through a reference with static type String.
Scene 1, Layer 'actions', Frame 1, Line 31136: Incorrect number of arguments.  Expected 2.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 19, 2012 Jun 19, 2012

Copy link to clipboard

Copied

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

     ...(ProgressEvent.PROGRESS, loop);

     ...(Event.COMPLETE, done);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 19, 2012 Jun 19, 2012

Copy link to clipboard

Copied

thanks that solved the problem

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 19, 2012 Jun 19, 2012

Copy link to clipboard

Copied

LATEST

You're welcome

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines