Simple Preloader with one movie loaded to target

If you want a bar, define a rectangle movie in its maximum size and give it the instancename "bar". frame 1: loadMovie("myMovie.swf","myTarget"); frame 2: // nothing in here frame 3: actBytes = myTarget.getBytesLoaded() || 0; totBytes = myTarget.getBytesTotal() || 100; percent = Math.round(actBytes * 100 / totBytes); if( totBytes - actBytes > 10){ // if you don't want a bar, delete the following line bar._xscale = percent; gotoAndPlay(2) } frame 4: // ready, go
alex barth Date: 23/08/2001

I tried this example ... it simply doesn\'t work. it seems that the call loadmovie(\"movie.swf\", \"target\") (i.e. a string as second argument) doesn\'t work at all at least in flash5. or is there some crucial line of code missing? alex
alex barth Date: 23/08/2001

GOT IT! sorry for the hasty posting before... the point is: \"mytarget\" has to refer to an already existing symbol (movieclip)... (i tried entering an arbitrary name, just thinking that i could DEFINE the referrer by doing so.) cheers, alex
evan Date: 03/09/2001

pretty sure i have this working as far as preloading. i can\'t get the damn bar to work though. it\'s set as a movie clip named \"bar\". also named \"bar\" in the instance field. i have it place on frame 3. i tried using a larger movie (35mb) to preload at the bandwidth profiler at 14.4. it hesitates (preloading?) but the bar never shows. any help? i really appreciate your simple no-frills approch to these matters!
Simen Brekken Date: 23/11/2001
I\'m looking at your code above, but there\'s one piece I don\'t understand: actBytes = myTarget.getBytesLoaded() || 0; I\'ve never seen the boolean or used in that kind of way, does it simply mean that the value on the right side of the || is used if the value on the left returns undefined or false? Is this the way you avoid the delayed getBytesLoaded() problem? Really great site BTW :)
semtex Date: 26/11/2001
Anyone care to post an example fla? I cannot seem to figure out ,which frames should be keyframes (is 2 a keyframe)? On which frame the movieclipholder should be placed. And if it needs to be on a separate layer.. And so on...I'm the visual type I guess. TIA! It's not working over here even if I give the myTarget mc the correct name and load the xternal one into that. Let alone the bar...
leland Date: 04/12/2001
why is it that the preloader seems to come up after about 60% of the movie is loaded? i modified this to work with just the main _root level instead of a movieclip and i can't even see the loader until about 60% into it, then it appears...
leland Date: 04/12/2001
i answered my own question...don't ya just love that? i figured out that it's linked items...anytime you have a linked item in the library it will download that before ANYTHING else in the movie...this includes preloaders...anyone have a way around it? i tried linking the item that i wanted to come in first and that didn't work either...
.d.hostetler Date: 02/02/2002
Great site. Any ideas on why the movie would hang on the second frame until the entire external swf was loaded? thanks again
vani Date: 05/09/2002
I m not getting the desired output. Where should i keep mytarget movieclip, means in which frame.then u have mentioned 4th frame ready go. But i dont have anything in 4 . So please clarify this
Shiva Date: 05/09/2002
hi. this seems to have a minor change. can you please send an example file so that we can try out. That would help us a lot as I need the code immediately. Thanks a lot !
MiniMe Date: 11/09/2002
Is there a way to display the time remaining too ??? Thanks MiniMe
mojo Date: 09/10/2002
hi there... the preloder is working great, i've been looking for this example for sometime now. however, once the movies are loaded/cahced, the preloader pauses on "100%" before going on... can I place an if statement that detects whether the movie is already loaded, and if so, then it jumps right to the go frame? what would that if statement look like? cheers...
Aedan Date: 23/11/2002
Can some1 send me and example to my e-mail - aedan_man@hotmail.com or send a url to download an example?
Faheem Date: 20/12/2002
hum...em trying to modify that preloader.. so that i can use it more than one time in same movie...i put the preloader in a Mc on root the code is like... lodBytes = /:abc.getBytesLoaded() || 0; totBytes = /:abc.getBytesTotal() || 100; totalPercent = Math.round(lodBytes * 100 / totBytes); totalKB = Math.round(totBytes/1024); loadedKB = Math.round(lodBytes/1024); kbTxt = loadedKB+"KB OF "+totalKB+"KB"; percentTxt = totalPercent+"%"; bytesTxt = lodBytes+"Bytes OF "+totBytes+"Bytes"; setProperty("bar", _xscale, totalPercent*2); if( totBytes - lodBytes > 10){ gotoAndPlay(2); }else { stop(); } NOW here me passing "/:abc" from root em trying this condeation... BUT its not working if( totBytes - lodBytes > 10){ gotoAndPlay(2); }else { stop(); } but whatn i use if( totBytes - lodBytes > 10){ gotoAndPlay(2); } it works... what i noticed that is... lodBytes = /:abc.getBytesLoaded() || 0; totBytes = /:abc.getBytesTotal() || 100; isnt working correct the movie stop at start and %age appears as 100%.. ??? any suggestion plz...i tried a lot but got nothing out of it !!
kristian Date: 15/03/2003
this is a code for external preloader on my site http://www.neotek.co.yu/neo hote thath the size of ext. .swf is fixed in ActionScript code it is the only way to work. if i do if (nloaded == total) the unloadMovie is unload write away. how to make the code universal for any size of external .swf? preloader is in one frame! hold.loadMovie("00.swf"); //hold is a target movie clip off stage this.onEnterFrame = function(){ nloaded = this.hold.getBytesLoaded(); total = this.hold.getBytesTotal(); _root.preload.proc = int(nloaded*100/total); if (nloaded == 52540){ //52540 is the size of 00.swf hold._x =0; hold._y =0; unloadMovie("preload"); } };
kristian Date: 15/03/2003
o yeah the preload is a movie clip on stage while loading.. external and proc a variable of dinamic txt box that shows the procentige.
jkljkl Date: 26/05/2003
:)
N\'Wan Date: 12/10/2003
Thank you kristian :) It works for me ^-^\
Henrik Date: 04/02/2004
Thank you, so much! Great help! Regards / Henrik
martin Date: 07/03/2005
this work for loading jpgs tooo ?
Add comment
Home