0

I have coded a game in AS3 without using classes and external as files. It works perfectly fine and whenver I try to incorporate a loading screen for it, I fail badly. This time I used the following tutorial for making my game's loader.

Tutorial: https://www.youtube.com/watch?v=gfcRm6SAYJI

Now, for the person in the tutorial, everything seems to be working fine. But for me, when I stimulate download, it shows white screen and then when it loads, the play screen is shown. Also, the white screen lasts for the time till my bandwidth profiler shows me that the download is done 70%. Then it turns to the loader and it loads after 70%. and then my play screen shows up.

How to rectify this?

I used the following code:

import flash.events.Event;
stop();


addEventListener(Event.ENTER_FRAME, loader);
function loader(event:Event):void
{
 var total:Number = this.loaderInfo.bytesTotal;
 var loaded:Number= this.loaderInfo.bytesLoaded;
 var percentage:Number= (loaded/total)*100;
 
 progressbar.scaleX=percentage/100;
 percentage_text.text=String(percentage);
 if(loaded==total)
 {
 trace("loaded");
removeEventListener(Event.ENTER_FRAME, loader);
  gotoAndPlay("Soundloader");
 }
}
Also, I have read in many tutorial posts that if I make my imported files like MCs and buttons and png files "Export for ActionScript" and then deselect "Export in first frame" it might help. I did the same but still the problem persists. Any help?
Mana
  • 352
  • 5
  • 22

1 Answers1

0

Also, I have read in many tutorial posts that if I make my imported files like MCs and buttons and png files "Export for ActionScript" and then deselect "Export in first frame" it might help. I did the same but still the problem persists. Any help?

That's incorrect, do not do that. If you export your assets in the first frame, flash player will first load all the assets in this frame and THEN execute your script. It cannot be backwards, if it executed your script without the assets loaded, what would it reference and show exactly? That's why you are seeing the 70% -> your assets are already at 70 percent loaded when the script fires.

If you need to export your assets in the first frame (which most of the time is the case), make a different loader file so you will have two swf's - one is the preloader, other one your 'main' file.

It is very easy, I could just copy you the script here but as far as I remember (it's been a long time), this video tutorial explains it quite ok: http://gotoandlearn.com/play.php?id=85

Fygo
  • 4,555
  • 6
  • 33
  • 47
  • I have tried the 2 swf method a lot of times before but my file never worked for that method. I also mentioned "Deselect" the "Export in first frame". Are you sure it will still load? Even if don't do it, it loads after some 70%. – Mana Apr 19 '15 at 03:19
  • Don't you have some assets on the first frame then? (on the stage/timeline) The external preloader must work, post your code. – Fygo Apr 19 '15 at 05:13
  • http://stackoverflow.com/questions/28621751/error-when-loading-swf-game-while-stimulate-download-but-not-normally – Mana Apr 19 '15 at 07:32
  • I had these troubles even before. It'll be a help if you could solve it there. I couldn't figure it out at all and it was very unclear and trying those solutions lead me nowhere. – Mana Apr 19 '15 at 07:33