View Full Version : preloading swfs
TRINI
10-02-2002, 12:14 AM
Well i think this one is simple for most people, but n e ways:
I got the loadMovie command to load swf sound files in an empty MC. What I would like to have, is a Preloader bar show up when the swfs are called. N E help will make my life happier.
-TRINI
Jesse
10-02-2002, 12:17 AM
http://www.actionscripts.org/showMovie.php?id=42
Pls remember to search the forums before posting.
TRINI
10-02-2002, 12:23 AM
I thought I did check the tuts. Awel.
TRINI
10-02-2002, 12:38 AM
After cheking out that movie link, I realize that it does not solve my problem. I need an actual PRELOADER for the MC, not just a bar with a motion tween!
CAN N E ONE HELP ME!?
-TRINI
Jesse
10-02-2002, 12:42 AM
That IS an actualy preloader. The bar is used to indicate the progress based on the percentage loaded (which you can also display if you want to - take a look at the code).
TRINI
10-02-2002, 12:56 AM
hmmmm. wht is the point of the 2 dynamic text fields?
Jesse
10-02-2002, 01:32 AM
They're supposed to show the bytes loaded and bytes total but the paths to the variables are wrong. Never picked up on that before.
TRINI
10-07-2002, 12:36 AM
Damn this is frustrating.
k, I got the preload bar rolling, and everything works perfectly when i test the movie.
But when i up-load it to the net, the preload bar just sits there, and doesnt move.
What's going on????????
Help please!
fabolous
10-08-2002, 06:16 AM
Could you post the fla so we can see where u went wrong?
TRINI
10-09-2002, 12:28 AM
The FLA contains a wav file, and is way to big to post.
I believe that the problem is with the CALLING of the swf. The swf and its preload bar works perfectly when I test it on its own, but when I test the actual FLA that calls it, the bar just sits there and doesn't move.
What could be up?
fabolous
10-09-2002, 12:37 AM
well that could possibly be the problem if you are exporting the wav file for actionscript from your library do you have export to first frame checked?... then the preloader won't execute untill the sound is loaded... why wav... mp3?
TRINI
10-09-2002, 12:55 AM
"export to first frame"? Where's that located?
I used a wav instead of an mp3 becuase I was lazy, but whats the diff- the SWF compresses the wav n e ways.
I apprieciate ur help btw.(-: I know I suk!
fabolous
10-09-2002, 01:02 AM
well where is your wav file? is it on a frame, mc or somewhere else?
when u right click on the wav file that is on your library then you will see a pop up menu that will have an option by the name linkage, the export to actionscript check box and the options are there... but if you didn't do this, it's probably not the problem...
TRINI
10-10-2002, 05:01 AM
The WAV file is on the timeline.
Im not sure if you understand my problem entirely, so I'm going to explain it proper:
I have a movie.
I'm calling an swf into this movie into an empty MC.
The swf contains the sound, and the preloader.
When I test the swf by itself, the preloader works perfectly.
However, when I test the movie, and call the swf, the preload bar just sits there, and doesn't move.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
So, the wav is in the swf, it's not the prob.
There are some preloaders on this site (searching is good) which work in different ways. I've got one going which does the preload thang generically from the _root swf (the one embedded in html), and then tells the loaded movie to goAndPlay a start label the loading swf's first frame action is stop();. This kind of approach is good, because it just works whenever anything gets loaded; I can give you a run-down if you like...
Are you testing locally through a browser (ie. publish swf, then reloading your htm file or whatever), or from with flash? What version flash?
I suspect the preloader just looks like it is working, but not really?
TRINI
10-10-2002, 10:32 PM
Im using this preloader:
total_bytes = _root.getBytesTotal();
loaded_bytes = _root.getBytesLoaded();
remaining_bytes = total_bytes-loaded_bytes;
percent_done = int((loaded_bytes/total_bytes)*100);
bar.gotoAndStop(percent_done);
ifFrameLoaded ("Scene 1", 1921) {
gotoAndPlay("Scene 1", 1);
}
I'd love to hear more about yours!
I'm testing the swf from within flash.
I've got MX.
Ive used this preloader before, and it worked perfectly. I've just never used it on a CALLED swf.
arrrrrrrrrrrrrrrg. thks 4 ur helpssssss!!!
OK, here we go - hope it's not too over the top for ya, but the basic idea is...
1.>>>> The preloader is an mC (movieClip), on the main (_root) timeline, and is always present. It has the following code attached, telling itself to turn of or on, depending on the value of the loadVisibility variable (which gets declared in the preload() function):
onClipEvent (enterFrame) {
this.loadbar._width = _root:barWidth;
if (_root:loadVisibility == "off") {
this._visible = false;
// tells the preloader to play a frame which skips
// all of that progress bar stuff.
this.gotoAndPlay("wait");
}
if (_root:loadVisibility == "on") {
this._visible = true;
// tells the preloader to go to a bit which has the load bar stuff, etc.
this.gotoAndPlay("start");
}
}
2.>>>> This method requires you to load any external movies that you want preloaded, into an instance of a blank mC which has the following code attached:
onClipEvent (enterFrame) {
// checks if this host clip contains an external .swf file or not...
if (this._url != _root._url) {
// ...call our preload() function, which displays the
// loading .swf file's download progress.
_root.preload(this);
}
}
3.>>>> Then we jam this function on the first frame of your _root level swf (the one that is embedded in your html file):
function preload(theClip) {
if (!theClip.doneLoading) {
if (theClip._framesloaded>0 && theClip._framesloaded == theClip._totalframes) {
// if the new swf has loaded in the blank mC, set the doneLoading variable,
// which is used in the above IF statements.
theClip.doneLoading = true;
// set all the preloader stuff to zero and make invisible...
barWidth = 0;
// loadVisibility variable is used by the preloader mC to be visible or not...
loadVisibility = "off";
bytesLoadedOutput = "";
bytesTotalOutput = "";
percentOutput = "";
// tells the newly loaded swf to play it's "start" label. So, the new swf
// must have a stop(); action on the very first frame, and also
// must have a "start" label, which will effectively be the first frame
// with actual content...
theClip.gotoAndPlay("start");
}
// if the new swf has not loaded yet, do the preloader stuff...
bytesLoadedOutput = Math.round(theClip.getBytesLoaded()/1024);
bytesTotalOutput = Math.round(theClip.getBytesTotal()/1024);
percentLoaded = Math.round((bytesLoadedOutput/bytesTotalOutput)*100);
percentOutput = percentLoaded+"%";
barWidth = (140*(percentLoaded/100));
}
}
3.>>>> So, (after you are sure the first the _root swf has fully loaded!) load your movie into the blank mC, via a button or whatever:
on (release) {
// load the movie into a blank mC with an instance of myBlankMovieClip
myBlankMovieClip.loadMovie("myFolderPath/intro.swf");
// set the loadVisibility variable to "on", which turns on the preloader mC...
loadVisibility = "on";
}
Once the preloader is going, it shows the download progress, manages the download (plays the new mC when fully loaded), then turns itself off...
Loading new mC's into that blank mC will unload whatever has is currently loaded; or you can load another new swf into a fresh blank mC.
Does this make any sense?
It's a hassle to set all of this up, but you'll only ever have to do it once; that's the nice bit. See it working here (http://www.fixedwing.com.au).
It can be tricky testing a preloader locally, best to test it over a slow modem connection, in a browser wondow - not in flash.
Gosh.
TRINI
10-11-2002, 01:33 AM
Holy George-terrorist-Bush that looks like alot of work!!
I'll give it a shot though.
Ure wikid man!
Don't let it overwhelm you!! Don't be afraid!
Spend the time now, it's sure to save plenty later...
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.