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");
}
}