|
-
How to ensure random external swf is fully loaded before moving to new frame [F8]
I am randomly loading external swfs into my main movie. I've got the random part working. However, I don't know how to make sure the random swf is fully loaded before jumping to a specific frame in my main movie.
I have a preloader inside each external swf, but I don't know how to make my main movie understand that the random swf is completely loaded before the main timeline should gotoandPlay("start").
What I Have So Far:
I have a blank MC (named "location") on the main stage, which I am using to hold the random swfs. On the first frame inside this MC, I have the following code:
choice = Math.round(Math.random()*2);
switch (choice) {
case 0 :
location.loadMovie("image0.swf");
break;
case 1 :
location.loadMovie("image1.swf");
break;
case 2 :
location.loadMovie("image2.swf");
break;
}
Loading the random swfs is working perfectly. But after the external swf is fully loaded, I want to move onto a frame labeled "start" on the main stage. I just don't know how to make sure the random swfs are completely loaded before I say gotoandPlay("start").
I've tried piecing together bits from so many tutorials, and I just don't know what I need to do to make it work with my current code.
Thanks so much!
Last edited by lsterling03; 08-28-2007 at 12:33 PM.
Reason: edited to include flash version
-
Developing For Dunkets
instead of using loadMovie you can use the MovieClipLoader class that has the onLoadInit function that checks if an external swf is loaded including it's actions.
var mcl:MovieClipLoader = new MovieClipLoader;
choice = Math.round(Math.random()*2);
switch (choice) {
case 0 :
location.loadClip("image0.swf");
break;
case 1 :
location.loadClip("image1.swf");
break;
case 2 :
location.loadClip("image2.swf");
break;
default ://add a default in case the switch fails for some reason
location.loadClip("image0.swf");
break;
}
mcl.onLoadInit = function(){
//add the actions you want to happen when the movie is loaded
}
mcl.addListener(this);
Last edited by mneil; 08-28-2007 at 01:51 PM.
Reason: you should add a default to your switch
-
Thanks for your help!
I tried the code you provided, and I received an error saying "there is no property with the name 'onloadInit'.
Do you know what the problem is?
Thank you!
-
Developing For Dunkets
sorry I always construct it wrong and forget the object:
var mcLoader:Object = new Object();
choice = Math.round(Math.random()*2);
switch (choice) {
case 0 :
mcl.loadClip("image0.swf", loacation);
break;
case 1 :
mcl.loadClip("image1.swf", loacation);
break;
case 2 :
mcl.loadClip("image2.swf", loacation);
break;
default ://add a default in case the switch fails for some reason
mcl.loadClip("image0.swf", loacation);
break;
}
mcListener.onLoadInit = function(){
//add the actions you want to happen when the movie is loaded
}
var mcl:MovieClipLoader = new MovieClipLoader;
mcl.addListener(mcLoader);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|