We have reduced support for legacy browsers.

What does this mean for me? You will always be able to play your favorite games on Kongregate. However, certain site features may suddenly stop working and leave you with a severely degraded experience.

What should I do? We strongly urge all our users to upgrade to modern browsers for a better experience and improved security.

How to use preloader

I’m probably just confused, but how exactly do you load assets with the preloader? I’m using flashdevelop and the preloader that is built in doesn’t seem to actually load anything, they just give you the space to display progress.

So to load with the preloader all I have to do is embed assets into the preloader and save them as global variables or something? Wouldn’t this increase the size of my game, which is why you would use loading in the first place?

It wouldn’t increase the size, that I know of. Just embed stuff the preloader needs in the preloader class instead of wherever else it is. For example, I have a class (Asset) that pretty much contains all images, sounds, music, etc. If I tried to have my preloader pull stuff from there, the _entire_ thing would need to load before it could be used, thus defeating the purpose of the preloader.
Oh, and they don’t need to be global variables—something like this would be just fine:
`
[embed code for some loading bar image]
private static const LoadingBar:Class;
[embed code for a play button]
private static const PlayButton:Class;
`
…etc. Since you don’t need to access them outside the preloader, you don’t need to make them global/public/whatever.

I should probably figure out how to make a preloader, but it’s all too hard…(I’m too lazy).
Normally, your game will load everything, then it will start. This leads to a period of black screen before your game starts, while it loads.
But if you have a preloader, the game just loads the things needed for that (couple of images and a bit of code), before it starts the preloader while it loads the rest of the game. So you don’t have a black screen for 20 minutes while all your pics/music/code loads.
I think I’m reasonably close?

[This](http://www.fastswf.com/UwYHtfQ) is generated by [this code](https://raw.github.com/Senekis93/GITD_Template/master/src/Preloader.as) (FD preloader template).
Read it and understand how it works. You don’t need to use the Preloader.as file to embed the assets; it simply display whatever you tell it to display while it loads the embeded stufff in the whole application.

For a simple preloader, you don’t need to explicitly preload anything. Just add assets (through [Embed(…)] metadata) to display objects which are loaded from the main class ( **not** from the preloader), and they’ll end up on the second frame (which is referenced from your main class).

> *Originally posted by **[Arloistale](/forums/4/topics/316603?page=1#posts-6681580):***
>
> So basically I don’t need to do anything in the preloader? Do you guys have any suggestions as to when in the game I should load using URLLoader? I’m not sure when an appropriate time to load is.
You can use URLLoader any time after your main class is called, not within the preloader.

BobJavona you only add the assets if you want to display anything in the preloader right? Otherwise anything that is embedded in the main class is loaded by the preloader? I already have the preloader provided by FlashDevelop. And Elyzius I know you can use URLLoader anywhere, I meant when should I do it? Should I load before the menu is created or the game is started?

To display any graphical images or have music in your game, you need to embed it somewhere. If it is embedded somewhere that is referenced by the main class, it will be ‘preloaded’, i.e. your preloader will display progress for loading that item.
You should only embed things in classes referenced directly from the preloader if you want to use them in the preloader.

Oh okay, thanks for clearing that up. About URLLoader, all the games that I’ve played so far on Kongregate only load at specific points, like before the menu or before the game. I was wondering what the best practice for when to load is.

As I haven’t used Flash Develop before, I’m not entirely sure what I’m talking about, but I think your preloader should load all of your game’s assets (if that’s possible) rather than you loading them in the middle of a game, unless your game has some strange dynamic universe or something…
So, your preloader will have a couple of things embedded (a few pics or something) but it will load everything else that is embedded in the whole game (I think, based on previous replies). Generally, I’d say you would want to load all of your game’s content during that period, rather than having pauses in the game to load more stuff as you go.

Isn’t URLLoader supposed to be the preferred way to load data like XML? So if I wanted to save and load stuff like level data I would need to use URLLoader? If I instead embedded many levels into my game wouldn’t that make it too big?

If you’re just representing the levels with a list of certain numbers, like level 1 = [1,26,2,2,4,6,7] or something, then just include it in the code. If your levels are represented by thousands upon thousands of lines of text, either, you’re doing it wrong or you might need to look for an alternate means.
But a few lines of text won’t impact the size of your game. The size of your game is mostly images and sound. Unless you’re in dire need or you’re doing custom user created level sharing, I’m not too sure why you’d need to load levels while the game is running.
If anyone has more knowledge than me though, feel free to step in.

> *Originally posted by **[Arloistale](/forums/4/topics/316603?page=1#posts-6691144):***
>
> Isn’t URLLoader supposed to be the preferred way to load data like XML? So if I wanted to save and load stuff like level data I would need to use URLLoader? If I instead embedded many levels into my game wouldn’t that make it too big?
This depends on what your levels are. Mine include a background (static image) and even then are pretty small. Yours might be just a set of numbers (be the set big, it’s still small compared to a single sound), if so, you are already good for embedding.
And yes, about loading XMLs. See, an XML is just a string, why should it not be contained in your file? If you use JSON, the same, you just use another means to parse it. So you go [embed] with a file, set it mime-type as ‘application/octet-stream’ and use a “new XMLStoredLevel()” as a ByteArray – it can be parsed as String should you need this afterwards.