PDA

View Full Version : Preloading best practices?


livingc
02-26-2009, 09:21 PM
For an entire site, is it better to

1. Put a preload.swf (with only preloading script) on the main index.htm page and load my main movie into that?

OR

2. To have preloading script internally at the first frame of the main movie (with mainmovie.swf on my index.htm page instead of a preload.swf file)

kkbbcute
02-27-2009, 05:59 AM
I do both actually, but my code screws up more often with the first example as compared to the second one, maybe due to my use of _roots, I'm not sure, neverr bothered to check. But anyway many people prefer the first method, but well, it actually really doesn't make much of a difference.

atomic
02-27-2009, 06:14 AM
Easier & better in most cases to use a separate preloader only movie... Even with AS3.0...

The attached is such an AS2.0 preloader only movie...

kkbbcute
02-27-2009, 06:24 AM
Easier & better in most cases to use a separate preloader only movie... Even with AS3.0...

The attached is such an AS2.0 preloader only movie...

Haha, I knew it, that's what most people say, though I haven't actually encountered a situation where doing so would give me a large benefit yet, so it's all actually up to you.

atomic
02-27-2009, 01:45 PM
:rolleyes:

maskedMan
02-27-2009, 02:24 PM
I would most highly recommend using a shell swf whose only job is to load content. It lets you export on frame 1 in your content swfs without worrying about how long it takes your preloader to start up, which is a nice convenience. It also is good practice if you want to be able to load many swfs.

The only drawback to this is that in AS3 when you load an external swf, you can't instantiate a new instance of your loaded content. (Or rather you can but it is a big pain and still might not work correctly even if you succeed). Not that it is likely you'll want to create a second instance of a website, but do keep that in mind if you want to say, import and clone a loaded asset.

maskedMan
02-27-2009, 05:37 PM
Haha, I knew it, that's what most people say, though I haven't actually encountered a situation where doing so would give me a large benefit yet, so it's all actually up to you.

This is because you have not worked in the industry yet. I have had to rewrite more than my share of code that made liberal use of _root. When you're a sole proprietor or you have no intention of making your applications portable, you probably don't worry so much about this. If your apps are self-contained and well-encapsulated though, you can use them in many different situations.

yell0wdart
02-27-2009, 06:54 PM
What maskedMan and atmoic said. Cleaning up messes caused by poor development practice is no fun at all.

atomic
02-27-2009, 07:10 PM
atmoic :confused::o

lol!

yell0wdart
02-27-2009, 09:26 PM
atmoic :confused::o

lol!

Lack of proof reading FTL. ;)

atomic
02-27-2009, 09:33 PM
Back on topic...

Link removed.

kkbbcute
03-01-2009, 11:17 AM
This is because you have not worked in the industry yet. I have had to rewrite more than my share of code that made liberal use of _root. When you're a sole proprietor or you have no intention of making your applications portable, you probably don't worry so much about this. If your apps are self-contained and well-encapsulated though, you can use them in many different situations.

Actually I knew the problems with _roots a long time ago, its just that like you said, I don't have a need to do so just yet.

tadster
03-15-2009, 02:21 PM
@ livingc
Number one is best for these reasons:

Most browsers try to stream in your flashes, but some want the whole file to be loaded first before they display anything,
so with a preloader scene the graphics of the scene will need to be loaded first before anything will be shown, which creates a gap between the movie loading into the browser and the display of any preload graphics.

using a separate swf as the loader would defeat the above, because a swf dedicated to loading others is normaly less than 5kb
and would get totally loaded fast and displayed right away even on dial-up.

also if you have the need to not have your main swf get cached, using a separate loader swf is the way to do that, (I've posted about nocahce methods in the html/scripting section)

hope this helps

kkbbcute
03-16-2009, 10:54 AM
Most browsers try to stream in your flashes, but some want the whole file to be loaded first before they display anything


I think that there is a workaround for this one that doesn't involve using an external container, will try to look around, though I agree that just using an external container is much easier.

eddiewireless
03-18-2009, 03:42 AM
I am not going to add anything about the pre-loader, becuase this subject has been covered on this forum WAY to many times...

-I found it that most developers like to work on the pre-loader last, and this always gives scope issues and force the developer to modify his script, and lets face it once you're done with a project the last thing you want to do is go over all your scrips looking for _root...what I like to do is create a root class for every project and assign the _root to a static variable that I use in my script.

So inside my script I'll have something like R.r.mc instead of _root.mc
R.r.mc

class R{
static var r:MovieClip=_root;

}

This saved my ass many time

kkbbcute
03-18-2009, 10:33 AM
I am not going to add anything about the pre-loader, becuase this subject has been covered on this forum WAY to many times...

Point is anyone new here would just start a new thread instead of looking at old ones, I think we should seriously have a section for "Common AS Problems".:)