Preloader Not Appearing Until 100% Loaded [SOLVED]


(Jonathan Stoler) #1

So I made a preloader for the first time using this thread as a guide.

But what happens when I try to load the game is that the screen remains blank for several seconds (so everything can load), THEN the preloader appears, instantly jumps to 100%, and then the game starts.

Obviously this completely ruins the point of having a preloader in the first place. I’ve done some searching around, and it seems that I need to make my content (graphics, sounds, etc.) load on frame two, and the preloader on frame one. Evidently this can be done from within the movie timeline in Adobe Flash. But I’m programming this by hand and using flex to compile it, so I don’t have a little dialog box that lets me change this.

Any advice?


(Ultima2876) #2

Try adding this compiler argument:

-frame Main com.mypackagename.Main

Where com.mypackagename.Main is your Main class including package structure. For example I have mine in the com/lunaticpandora folder (com/lunaticpandora/Main.as) so I use:

-frame Main com.lunaticpandora.Main

If you don’t have your Main.as (Main class) in a package folder, just use:

-frame Main Main

That will add your Main.as and all the rest of the FlashPunk stuff as a separate frame.


(Jonathan Stoler) #3

Thanks!

I’m using flex 4.6, and I had to do this instead:

-frame=Main,Main

(your argument produced an error that suggested this syntax instead)

But the point is: it works!

Another snag I ran into was that you need to use getDefinitionByName in combination with this. On its own, getDefinitionByName didn’t work for me, but after including this argument, it’s all good!


(Bora Kasap) #4

Hey guys, i’m trying to do that preloader stuff for a long time even adding compiler options for real main class but then i’m getting an access error when it succesfully loads the swf and runs the real main class.

the error is on the line 42 of my main.as class, i have no errors if i use this as document class but using preloader as document class.

so, what i have on the line 42

i have this, thats kong stuff for loading kong api

var paramObj:Object = LoaderInfo(root.loaderInfo).parameters;

but i cant access that root loader info stuff when main class is not document class anybody knows how can i solve this problem?

it gives that classic error about null object reference


(Bora Kasap) #5

i think i’ve solved that after all

i’m loading api in the preloader that looks fine for now, hope no more troubles