To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash Newbies

Reply
 
Thread Tools Search this Thread Display Modes
Old 08-28-2007, 01:21 PM   #1
lsterling03
Junior Member
 
Join Date: Feb 2006
Posts: 12
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 01:33 PM. Reason: edited to include flash version
lsterling03 is offline   Reply With Quote
Old 08-28-2007, 02:49 PM   #2
mneil
I want my 2 dollars
 
mneil's Avatar
 
Join Date: Mar 2007
Location: Bakersfield
Posts: 2,044
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);
__________________
http://www.mneilsworld.com/
Text Effects | Bubbles | Dynamic Resize
4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

Last edited by mneil; 08-28-2007 at 02:51 PM. Reason: you should add a default to your switch
mneil is offline   Reply With Quote
Old 08-28-2007, 06:43 PM   #3
lsterling03
Junior Member
 
Join Date: Feb 2006
Posts: 12
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!
lsterling03 is offline   Reply With Quote
Old 08-28-2007, 07:02 PM   #4
mneil
I want my 2 dollars
 
mneil's Avatar
 
Join Date: Mar 2007
Location: Bakersfield
Posts: 2,044
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);
__________________
http://www.mneilsworld.com/
Text Effects | Bubbles | Dynamic Resize
4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!
mneil is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash Newbies

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:31 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.