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

Problem with Preloader in my Flash AS2 Game

New Here ,
Mar 12, 2011 Mar 12, 2011

I have been using this tutorial to make a preloader:

http://www.republicofcode.com/tutori.../preloader_bc/

I have run into one problem though.
When I simulate the download, it just shows the background color of the game while it loads, and when it finished loading, it shows the loading screen fully loaded. I have followed the tutorial exactly, except added my file names into the AS2 code.

Here is the ActionScript in Frame 1 I have for the preloader:


if (_root.getBytesTotal() != _root.getBytesLoaded()){
stopAndGoto(1);
}
preloaderBar._xscale=(_root.getBytesLoaded()/_root.getBytesTotal())*100;
loaderTxt.text=Math.round((_root.getBytesLoaded()/_root.getBytesTotal())*100)+"%";



Any hints or answers to what i'm doing wrong?

Thanks, MrA615.

TOPICS
ActionScript
2.1K
Translate
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 , Mar 14, 2011 Mar 14, 2011

Place your other objects in frame 3 (or higher) of other layers

Translate
LEGEND ,
Mar 13, 2011 Mar 13, 2011

Your description of what you've done and the code you show does not match what the tutorial says to do and what code to use... (there is no stopAndGoTo() function in Flash).

Right-click the second frame on the upper layer labeled Actions and select Actions. Copy and paste the code below to make our preloader functional.

 

if (_root.getBytesTotal() != _root.getBytesLoaded()){
gotoAndPlay(1);
}
bar_mc._xscale=(_root.getBytesLoaded()/_root.getBytesTotal())*100;
loader_txt.text=Math.round((_root.getBytesLoaded()/_root.getBytesTotal())*100)+"%";

Translate
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 ,
Mar 13, 2011 Mar 13, 2011

Thanks for replying.

I have just noticed that, tested it out by simulating the download, and it still doesn't work. When it loads, I can see that it is loading all the bytes, but it is not showing the preloader screen.

Here is my code as it is now.

if (_root.getBytesTotal() != _root.getBytesLoaded()){
gotoAndPlay(1);
}
preloaderBar._xscale=(_root.getBytesLoaded()/_root.getBytesTotal())*100;
loaderTxt.text=Math.round((_root.getBytesLoaded()/_root.getBytesTotal())*100)+"%";


Would you like to see the .FLA file?

MrA615.

Translate
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 ,
Mar 13, 2011 Mar 13, 2011

If you can explain what you have done and maybe show a screenshot of your timeline, that will probably help.  One other thing... what size of swf file are you dealing with here?

Translate
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 ,
Mar 13, 2011 Mar 13, 2011

The SWF file is about 2 MegaBytes, and I don't think that should cause a problem. I also made the linkage for everything that was exported for ActionScript, had everything unchecked for "Export in first frame."

Here is a picture of the timeline. I have the background which is preBack, Bar/Percent which is the Bar Movie Clip and the text, and preAS which is the Action.

Preload_Glitch2.png

Also, when I simulate the download, I can see that it is loading, but shows the background color while it's loading. When it finishes, it just goes to the frame I commanded it to. (Frame 1)

Preload_Glitch.png

Translate
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 ,
Mar 13, 2011 Mar 13, 2011

Based on the timeline image you still are not doing what the tutorial instructs and what I pointed out that you need to do.  I do not see any code in frame 2, which  is where the code you showed is supposed to be.  And when you are done with the preloading, you would not go to frame 1, you would go beyond frame 2 somewhere, where the rest of your file content should be.

Translate
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 ,
Mar 13, 2011 Mar 13, 2011

I noticed that I had put the code in the wrong Frame. But now I switched the action to the 2nd frame, but still shows the background while it is loading.

Translate
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 ,
Mar 13, 2011 Mar 13, 2011

Your preloader textfield and loader bar need to exist in frames 1 and 2.  Maybe you should try going thru the tutorial again from the start, taking your time to follow each step.  There are tutorials that are sloppily done and miss explaining things, but everything that you missed doing so far is properly explained in the tutorial.

Translate
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 ,
Mar 13, 2011 Mar 13, 2011

Good News, I have started it from scratch, and it worked! But I noticed it only works if all of the content I want to load is in Frame 3 of the Content Layer. I have multiple layers of other objects to load. Any hints?

Translate
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 ,
Mar 14, 2011 Mar 14, 2011

Place your other objects in frame 3 (or higher) of other layers

Translate
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 ,
Mar 14, 2011 Mar 14, 2011

Yay! I worked! The only problem is that the loader bar shows up at about 90% loaded. Is there a way I can make that load first? And also, the text doesn't show up at all.

Translate
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 ,
Mar 14, 2011 Mar 14, 2011

^ (Ignore the post above) ^

It worked!

I have run into a few problems though:

1. The loading bar showed up this time, but only at about 90%

2. The text for the bar doesn't show up at all.

3. The Custom cursor image doesn't work.

4. One of my images is not showing up in Frame 3.

I assume these steps should be easy, but at least the loading bar actually showed up!

MrA615.

Translate
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 ,
Mar 15, 2011 Mar 15, 2011
LATEST

Actually, nevermind! Problem completely solved! Preloader finished!

Thanks for your time and help. MrA615.

Translate
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