Groups | Blog | Home
all groups > flash actionscript > march 2004 >

flash actionscript : Preloader help for an idiot (me)


mark_fredriksen
3/11/2004 8:43:17 PM
Hi. I need a bit of help with a preloader I'm working on. Here's the
situation: I have 20 swf files that were given to me that I need to package
into one larger flash movie. These 20 files are rather large in size (150kb to
600kb) so I want to make each of them preload when they are called for. The
general idea is a user clicks on link 1 and it loads that movie and plays it.
They can then click on link 6 and it then loads that movie and plays it. Can
anyone assist me, or point me in the direction of a suitable template to
follow? I'm so new to this that it's scary.

Tom
stwingy
3/11/2004 9:20:00 PM
preloaders are tricky when you are first starting. You can use this code to
load into levels or to load a single movie just leave out the
"createEmptyMovieClip("paper", 1);" and change function parameters.

This assumes your movies are named movie1.swf..........movie20.swf
and your buttons or links are btn1....btn20
//dynamic textfield on the same timeline - percent_txt

assessLoad = function (clip) {
var kbLoaded = Math.floor(clip.getBytesLoaded()/1024);
var kbTotal = Math.floor(clip.getBytesTotal()/1024);
percent = kbLoaded/kbTotal;
percent_txt.text = Math.floor(percent*100)+"%";
if ((kbLoaded == kbTotal) && kbTotal>1) {
endPreload(clip);
}
};
endPreload = function (clip) {
clearInterval(preload);
};
createEmptyMovieClip("paper", 1);
for (i=1; i<21; i++) {
_root["btn"+i].ivar = i;
_root["btn"+i].onPress = function() {
loadMovie("movie"+this.ivar+".swf", paper);
preload = setInterval(assessload, 50, paper);
};
}
AddThis Social Bookmark Button