PDA

View Full Version : Converting from movieClipLoader to loadMovie for flash player 6 compatibility - Help!


johnnyboy
01-11-2006, 03:19 PM
Hi there,

I've been trying to convert script with the movieClipLoader() to the more simple loadMovie(), so I can export my SWF for flash player 6, but I have a small problem with my preloading...

Heres my MCL:

/// MOVIECLIPLOADER ///
xLoadAllIMGs = function () {
for (i = 0; i < SWFs_num; ++i) {
my_mcl = new MovieClipLoader();
counter_str = i;

IMG = path + counter_str + ".swf"; // the image to be loaded
my_mc = "MC" + counter_str + "_mc"; // the movieclip that should contain the image above

preload = new Object();
preload.onLoadInit = function(mcTarget) {
//trace(mcTarget);
my_mcl.removeListener(preload);
xSetAllIMGs();
}
my_mcl.addListener(preload);

_root.CONTAINER_mc.createEmptyMovieClip(my_mc, CONTAINER_mc.getNextHighestDepth());
}

}
xLoadAllIMGs();


Instead I tried this:

/// LOADMOVIE ///
xLoadAllIMGs = function () {
for (i = 0; i < SWFs_num; ++i) {
counter_str = i;

IMG = path + counter_str + ".swf"; // the image to be loaded
my_mc = "MC" + counter_str + "_mc"; // the movieclip that should contain the image above

_root.CONTAINER_mc.createEmptyMovieClip(my_mc, CONTAINER_mc.getNextHighestDepth());
loadMovie(IMG, _root.CONTAINER_mc[my_mc]);

if (i == SWFs_num - 1) {
xSetAllIMGs();
}
}

}
xLoadAllIMGs();


But my xSetAllIMGs() function is on before the images are loaded...?

Should I use some kind of extra preloader in my loadMovie script???

johnnyboy
01-12-2006, 11:19 AM
Can nobody help me out here...?

I really need my movie to be Flash Player 6 compatible.

senocular
01-12-2006, 12:34 PM
this might be helpful:
www.senocular.com/flash/tutorials/preloading/

johnnyboy
01-12-2006, 02:03 PM
Thanks Senocular - I'll give it a go :)

johnnyboy
01-12-2006, 04:53 PM
I looked at the tutorial at your site senocular, and tried to use the example where you load external swfs.

But I can't seem to get all the swfs preloaded...

Here's my code:

function preloadContainer(){
// get bytes loaded and total from container_mc
var bytes_loaded = CONTAINER_mc.getBytesLoaded();
var bytes_total = CONTAINER_mc.getBytesTotal();

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;

// delete the onEnterFrame event handler running this function
delete onEnterFrame;

_root.gotoAndPlay(2);
}
}
}
onEnterFrame = preloadContainer;
////////////////////////////////////////////////////
xLoadAllIMGs = function () {
for (i = 0; i < SWFs_num; ++i) {
counter_str = i;

IMG = path + counter_str + ".swf"; // the image to be loaded
my_mc = "MC" + counter_str + "_mc"; // the movieclip that should contain the image above

_root.CONTAINER_mc.createEmptyMovieClip(my_mc, CONTAINER_mc.getNextHighestDepth());
loadMovie(IMG, _root.CONTAINER_mc[my_mc]);
}
}
// this trigger initiates all actions
xLoadAllIMGs();


As soon as the first image is loaded it plays frame 2, but I want it to load alle the images before it goes there...?

I have to load 40 images...

What am I missing...?

johnnyboy
01-12-2006, 05:25 PM
I have tried to simplify the code, but still no luck... still something wrong, but what??


xLoadAllIMGs = function () {
for (i = 0; i < SWFs_num; ++i) {
counter_str = i;

IMG = path + counter_str + ".swf"; // the image to be loaded
my_mc = "MC" + counter_str + "_mc"; // the movieclip that should contain the image above

_root.CONTAINER_mc.createEmptyMovieClip(my_mc, CONTAINER_mc.getNextHighestDepth());
loadMovie(IMG, _root.CONTAINER_mc[my_mc]);
}

for (i = 0; i < SWFs_num; ++i) {
counter_str = i;
// get bytes loaded and total from container_mc
var bytes_loaded = _root.CONTAINER_mc["MC" + counter_str + "_mc"].getBytesLoaded();
var bytes_total = _root.CONTAINER_mc["MC" + counter_str + "_mc"].getBytesTotal();

if (bytes_total > 0){
if (i == SWFs_num - 1){
_root.gotoAndPlay(2);
}
}
xSetAllIMGs();
}
}
xLoadAllIMGs();