The following preloader and code to laod the first swf is in the fiest frame of the main movie.
stop();
// this function runs the preloader
// it is to be used with the onEnterFrame
// of the preloader animation
function preloadContainer(){
// get bytes loaded and total from movieHolder
var bytes_loaded = movieHolder.getBytesLoaded();
var bytes_total = movieHolder.getBytesTotal();
// stop and hide the movie so it wont play or
// be seen while progressively downloading
// (keep trying if it exists or not just to be sure)
movieHolder.stop();
movieHolder._visible = false;
// if bytes_total is a valid number and greater than 0
if (bytes_total > 0){
// get percent loaded
var percent_loaded = bytes_loaded/bytes_total;
// update the value in the preloader
preloader_mc.value = percent_loaded;
// check if preloading is complete
if (percent_loaded == 1){
// play and show the container clip
movieHolder.play();
movieHolder._visible = true;
// remove the preloader movie clip
preloader_mc.removeMovieClip();
// delete the onEnterFrame event handler running this function
delete onEnterFrame;
}
}
}
stop();
// movie 1 loads the swf using startPreload
startPreload("ShopOutsideAnim01.swf");
// this function begins preloading a swf url
function startPreload(url){
// use loadMovie to load the swf url into container_mc
movieHolder.loadMovie(url);
// attach the preloader animation
// this will be removed when preloading is complete
attachMovie("preloader anim", "preloader_mc", 500, {_x:275, _y:165});
// set the onEnterFrame event to call preloadContainer
onEnterFrame = preloadContainer;
}
Once the swf loads a button can be pushed in the loaded swf which goes to the last frame where the below code is. I want at this point to preload another swf into the same location. It does not work. It does attach the preloader anim movie and load the swf, but it does not run the preloader function.
stop();
// movie 1 loads the swf using startPreload
LoadIt("ToolShopAnim01.swf");
// this function begins preloading a swf url
function LoadIt(url){
// use loadMovie to load the swf url into container_mc
_parent.movieHolder.loadMovie(url);
// attach the preloader animation
// this will be removed when preloading is complete
_parent.attachMovie("preloader anim", "preloader_mc", 500, {_x:275, _y:165});
_parent.preloadContainer;
}
In the child swf I should put this code:
_parent.startPreload("ShopOutsideAnim01.swf");
I was trying to create a new function in the child swf. I dunno this stuff drives me nuts. But I'm happy I figured something out!