How do you use a preloader when you are dynamically loading swf’s?? Could someone please explain how you do this…PLEASE…
For example I have the script in the main movie loading all the other swf’s dynamically, but the actual swf’s that are being loaded have the preloader script on the 1st frame of each movie…and this seems to be causing the problem…
This is the code in the main movie 1st frame…
stop();
//
//
// Set up the MovieClipLoader object and its listener
my_mcl = new MovieClipLoader();
my_listener = new Object();
my_listener.onLoadComplete = function(movieClip) {
trace("Loading is done for "+movieClip);
};
my_listener.onLoadError = function(movieClip) {
trace("Error: "+movieClip+" did not load anything.");
trace("Your load failed for "+movieClip);
};
my_mcl.addListener(my_listener);
//
//
// Setup the TextField.StyleSheet object
my_ss = new TextField.StyleSheet();
// Tell the CSS what to do when loaded
my_ss.onLoad = function(success) {
if (success) {
trace("myStyle.css loaded");
} else {
trace("myStyle.css did not load");
}
};
my_ss.load("styles/myStyle.css");
//
//
// Setup the LoadVars object
my_lv = new LoadVars();
my_lv.load("text/my_vars.txt");
my_lv.onLoad = function(success) {
if (success) {
gotoAndStop("Animation");
} else {
trace("Load Failed");
}
};
my_lv.getHome = function() {
return this.homeVar;
};
my_lv.getAbout = function() {
return this.stuffVar;
};
Then this is the code in the “Animation” frame of the main movie that loads the external swf dynamically…
// Use the MovieClipLoader from frame 1 to load some movieclips.
my_mcl.loadClip("animation.swf", "main_mc_container");
my_mcl.loadClip("navigation.swf", "navigation_mc_container");
Then for example this is the script that runs the preloader script in the movie that is being loaded dynamically into the main movie
bytes_loaded = Math.round(_root.getBytesLoaded());
bytes_total = Math.round(_root.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
_root.loadBar._width = getPercent*100;
_root.loadText = Math.round(getPercent*100)+"%";
if (bytes_loaded == bytes_total) {
_root.gotoAndPlay(5);
}