preload everything
- Started
- Last post
- 17 Responses
- jysta
This is probably really easy, but may require changing my flash site setup.
I currently have a pre-loader for each external SWF file. Whats the easiest way to pre-load all these at once at the begging of the Master.swf?
e.g. the user will only see one pre-loader at the beginning rather then a load of pre-loaders each time they load an external SWF file while viewing the site.
- ornj0
Why bother making them all external if you are going to just load them at once anyways?
- jysta0
:-? erm it's just how I've always organized my flash sites. I've only ever done it that way. Easy to manage I guess.
- ornj0
apparently not
- Mimio0
The easiest way is have a loader class run through an array of all your external swfs. Load one right after another.
- ********0
I posted a similar post not long ago, but got no real response from this board. Let me know if you make/find anything.
here is my post:
http://www.qbn.com/topics/442576…
- flashbender0
provided the external movies are empty in the first frame you could load them all into levels and then add up their bytesTotal and bytesLoaded...
loadMovieNum("movie1.swf", 5)
loadMovieNum(movie2.swf", 6)TotalBytesLoaded= Number(_root.getBytesLoaded() + _level5.getBytesLoaded() + _level5.getBytesLoaded() )
TotalBytes= Number(_root.getBytesTotal() + _level5.getBytesTotal() + _level5.getBytesTotal() )
Then just do the regular preloader stuff
- they can be loaded into invisible containers as well, don't need to have empty framesrafalski
- ********0
But what if the user does not want to see each section of the site? why not let the user load what he/she wants or needs to see?
- Mimio0
You can do all of this with the built in loader class and event listeners.
- ********0
Thanks for the response guys, I'm gonna give these a try. Before I get into it too deep, do you guys know if it works with xml, mp3, etc in addition to swf files?
- urban100
the one i provided can only be used for swfs and images. for mp3s/wav files you will need to use the loadSound() and onLoad() methods of the Sound object:
http://livedocs.adobe.com/flash/…
loading external XMLs has similar loading methods available, specifically the load() and onLoad() methods:
http://livedocs.adobe.com/flash/…
btw... i'm assuming you're using AS2. AS3 has different methods as things have changed quite a bit.
- flashbender0
I'ma a scerred of this AS3
- ugh same here... i have yet to really take the plunge into it, though i heard it's much better than AS2urban10
- but i am not a developer/nerd. i am merely a designer/idiot. AS3 seems to eliminate all hack jobs...which really scares melvl_13
- me :D
seriously these notes...i wish there was a letter count limit warning...shiiiitttt...lvl_13
- urban100
you can of course create a single function like my preload() that checks the extension of the file used in the array and then uses the appropriate methods... the following would be used inside preload():
var start:Number = src.lastIndexOf(".") + 1;
var ext:String = src.substring(start);
if (ext == 'swf' || src == 'png' || src == 'jpg') {
// load img
}
else if (ext == 'xml') {
// load xml
}
else if (ext == 'mp3' || ext == 'wav') {
// load audio
}
- jysta0
Could you not load the swf's at the beginning then re-load them all into the same 'container_mc', that way the SWF will be pre-cached or would that be bad practice?? Essentially loading the same file twice. In the attempt at avoiding loading into levels. I'm not OOP or experienced in actionscript so that suggestion may just sound like total nonsense.
Thanks for the feedback guys.
- urban100
jysta... not quite following you in your method to load twice. If you load the swfs into their container mc then you wouldn't be loading into levels necessarily... just depths within the container. also the use of levels in AS is typically bad practice (no longer used in AS3) in favor of using OOP and dot access for objects.
it's preferred to load your content into their own parent container rather than separate levels, which will make managing and accessing those objects in your actionscript elsewhere a nightmare. for example, in the method i described you could have something similar to (if you loaded all the items into a parent 'content_mc' movieclip and 'this' refers to the parent of 'content_mc', which could be _root depending on where you initialize it):
this.content_mc.mc1
this.content_mc.mc2
this.content_mc.snd1
this.content_mc.xml1- also some users may turn off browser caching, in which case it would not be cached the first time it was loaded and it would have to be loaded again.urban10
- mrbee28280
Here is a class I wrote but it needs some additions for loadvars.
- jysta0
Thank you again guys, very helpful.