PDA

View Full Version : preloader for loading external swfs


atslopes
11-24-2003, 02:56 PM
heres the site: http://www.rit.edu/~ast7707/portfolio.html
it works fine but how can i have simple preloader that loads the external swfs




on the first frame of the movie i have**********************


// set up variables for movie start
_root.swfAlert = "fadeout";
_root.swfNum = 1;
_root.swfNumMax = 4;
_root.containerPositionX = 162;
_root.containerPositionY = 79;
_root.fadeSpeed = 8;
// here is the function that loads the movie
// set swfNumMax to the number of movies you will want to import
// make sure you number your external movies "swf1", "swf2", "swf3", etc...
function loadSwf() {
// _root.swfNum++;
// if (_root.swfNum>_root.swfNumMax) {
// _root.swfNum = 1;
// }
// sets the current movie name to load
_root.activeSwf = "swf"+_root.swfNum+".swf";
// load the swf
loadMovie(_root.activeSwf, _root.container);
// set the x, y position
_root.container._x = _root.containerPositionX;
_root.container._y = _root.containerPositionY;
}
// load the first swf when the movie starts
loadSwf();


and on the container i have ***************************


//this enterframe script checks the value of "swfAlert" and does something depending on the returned result
onClipEvent (enterFrame) {
if (_root.swfAlert == "fadeOut") {
_root.container._alpha -= _root.fadeSpeed;
if (_root.container._alpha<=0) {
unloadMovie(_root.container);

_root.swfAlert = "load";
}
}
if (_root.swfAlert == "load") {
_root.loadSwf();
_root.swfAlert = "fadeIn";
}
if (_root.swfAlert == "fadeIn") {
_root.container._alpha += _root.fadeSpeed;
if (_root.container._alpha>=100) {
_root.swfAlert = "static";
}
}
}:o

Warrior
11-26-2003, 08:52 PM
Please use the "AS tags at the top to insert your code correctly. This question has been answerd so many times. Did you even use the search button or look at the >>preloaders That Work<< (http://www.actionscript.org/forums/showthread.php3?s=&threadid=32234) thread?

// Put this code 5 frames before the preloader
loadMovieNum ("1.swf", 1);
loadMovieNum ("2.swf", 2);
loadMovieNum ("3.swf", 3);

// Put a stop(); action on the Keyframe of the preloader
// This preloader must be on a movie clip.
onClipEvent (enterFrame) {
Total = (_level1.getBytesTotal()+_level2.getBytesTotal())+ _level3.getBytesTotal() + _root.getBytesTotal();
Loaded = (_level1.getBytesLoaded()+_level2.getBytesLoaded() )+_level3.getBytesLoaded() + _root.getBytesLoaded();
percent = Math.floor((Total/Loaded)*100);
display = percent+"% Loaded";
if (percent == 100) {
_root.gotoAndStop("Frame Lable");
}
}