Hi
I have a tutorial on how to preload external content by clicking a button.
I manage to make it work, but only when it is in the main time line, once I put it into a movie clip I cant seem to get the referencing right, and was hoping someone could help me out?
I know it shouldn’t be to much of a problem, it is just I cant figure it out.
The script I use is on the first frame in the main timeline, the buttons that the user can click, will be inside a movieclip called, " mainmovie "
the button is called " movie1_btn " and I have tried like :
_root.mainmovie.movie1_btn.onPress = function(){
startPreload(“load/tankoverhead.swf”);
}
but it doesnt work.
Anyway here is the script I use appreciate any help I can get. Thanks in advance
// 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 container_mc
var bytes_loaded = container_mc.getBytesLoaded();
var bytes_total = container_mc.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)
container_mc.stop();
container_mc._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
container_mc.play();
container_mc._visible = true;
// remove the preloader movie clip
preloader_mc.removeMovieClip();
// delete the onEnterFrame event handler running this function
delete onEnterFrame;
}
}
}
// movie 1 loads the tankoverhead swf using startPreload
movie1_btn.onPress = function(){
startPreload(“load/tankoverhead.swf”);
}
// movie 2 loads the tankturn swf using startPreload
movie2_btn.onPress = function(){
startPreload(“load/tankturn.swf”);
}
// this function begins preloading a swf url
function startPreload(url){
// use loadMovie to load the swf url into container_mc
container_mc.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;
}