Some Flash preloading issues you’d better know
I never used a preloader in a game… all my games are quite light, and I used to preload movies only in some heavy website intros.
Heavy, as I said, but 100% timeline and 0% actionscript
Today, I was making a preloader for Glomb, because I am dealing with a sponsor (yes… maybe I am giving Glomb for an exclusive sponsorship) when I come into a problem.
The preloader started loading when the movie was at 99% loaded.
I don’t think the sponsor would like his logo to be shown only at the 1% of the loading time, so I was wondering what was wrong with the preloader.
This was the code, in the 1st frame:
1 2 3 4 5 6 7 8 9 | stop();
onEnterFrame = function () {
already_loaded = _root.getBytesLoaded()/_root.getBytesTotal();
// show some fancy preloading graphics
if (already_loaded == 1) {
delete onEnterFrame;
play();
}
}; |
It’s a very common preloader, you may find it on a lot of tutorial sites and books.
But it did not work for me.
After a while, I solved the issue: most of the graphics and sounds in the game are not in the timeline… they are called dynamically by the actionscript with attachMovie or attachSound.
The problem is Flash compiler does not know when you are going to use those graphics and sounds, so it preloads all this stuff before the 1st frame. So when my preloader comes in action, the 99% of the movie (graphics and sounds) are loaded, then the remaining 1% (actionscript itself) is loaded showing the preloader.
This happens because you have this checkbox enabled

This checkbox determines the object must be loade before the 1st frame.
Never mind! Just uncheck it and everything will work fine!
This is not the solution… if you uncheck the checkbox, when the compiler scans the timeline and does not find the resource, it simply ignores it and your game will be compiled without graphics/sounds.
What can you do?
If your preloader is on frame 1, you should made your game start on frame 3, and put all your dynamically created objects at frame 2. This way, the movie will compile the objects because it finds them on frame 2, but the first thing to be loaded will be the preloader, and everything will work fine. Obviously, the Export in first frame mark has to be unchecked.
They can be easily customized to meet the unique requirements of your project.















(4 votes, average: 4.50 out of 5)









This post has 13 comments
colplayer
hey, nice job u’ve put here.I’ve got some of a nasty situation so i want to ask u HOW TO PUT A SWF FILE IN A WORDPRESS HEADER. It will really be great if u can help me. u’ve got my email there. u can write.10x very much
Faisal
I think I used that preloader before. But thanks for the heads up!
P.S. I sent you an e-mail, did you see it?
wildwobby
Cool tip, I never would have been able to figure that one out? Are the forums coming soon btw?
Frederik J
Nice. Looking forward to see the sponsorship.
abhilash
i don’t think this is useful for me becoze i don’t attach movie clips, but this will be useful for others.
what about your line rider tutorials, u wrote the last one in mid 2007 from then i am waiting for those tutorials…..
Lachy
Hey,
I filed a lookover on the warning about entering the page with the stop badware site and they seem to have taken it down, so i hope im responsible for getting it done because you deserve that for this blog :)
Thanks
nathan hunt
hi
Andre
I had this issue with one of my earlier games that didn’t have mochiads
Shadow Scythe
This is a very very very very useful thing that I will keep in mind immediately because I do believe you’ve solved a very annoying problem in one of my in-progress games. Thanks vera much!
Artus
Man you are great:) i have bet looking for this for ages and you told me hove to do this.:)
i allways use loadMovie() as preloader and it stinks:D this is beter one. Thx man.
brart
how do you preload the attachSound() things?
twyud
oh thank’s man, that’s good tutor
Jens Picks
How to attach preloader swf intro before people gets in main page ?