Solved

Actionscript 2 LoadMovie

Posted on 2009-05-05
6
1,014 Views
Last Modified: 2013-11-11
I'm not sure what I'm doing wrong with this code.  It seems to skip over the preloader and continue on.  I can put a bad file name into the my_mcl.loadClip(swfName, mc_holder); and i don't get an error, it just plays the next line.

I have a movie that loads some buttons.  After the user clicks a button, a variable is loaded with the name of the appropriate .swf  - after the buttons fade away, I do the loadClip code...

I've tried several different ways to do this, testing it on my computer - i can't get the external swf to load.  Here's the code i'm using:

stop();
if (swfName == ""){
      gotoAndPlay(3)
} else {
      trace("here");
      trace(swfName);
      var mclListener:Object = new Object();
      mclListener.onLoadError = function(target_mc:MovieClip, errorCode:String, status:Number) {
    trace("Error loading image: " + errorCode + " [" + status + "]");
      };
      
      mclListener.onLoadStart = function(target_mc:MovieClip):Void {
    trace("onLoadStart: " + target_mc);
      };
      
      mclListener.onLoadProgress = function(target_mc:MovieClip, numBytesLoaded:Number, numBytesTotal:Number):Void {
    var numPercentLoaded:Number = numBytesLoaded / numBytesTotal * 100;
    trace("onLoadProgress: " + target_mc + " is " + numPercentLoaded + "% loaded");
      };
      
      mclListener.onLoadComplete = function(target_mc:MovieClip, status:Number):Void {
    trace("onLoadComplete: " + target_mc);
      };
      
      my_mcl.addListener(mclListener);
      my_mcl.loadClip(swfName, mc_holder);
      gotoAndPlay(288);
}

I am not sure what's up.  This is code i found on the Adobe site...  any insight would be appreciated!!!
0
Comment
Question by:steverguy
  • 3
  • 2
6 Comments
 
LVL 39

Accepted Solution

by:
blue-genie earned 500 total points
ID: 24312086
i'm not sure what your setup is but if i copy and paste your code into a file and provide a swfName that doesn't exist I get error messages as expected.
where are you specifying your my_mcl.
you have a mc_holder on the stage?
where are you specifying the swfName variable?
0
 
LVL 1

Author Closing Comment

by:steverguy
ID: 31578305
Thank you!
0
 
LVL 1

Author Comment

by:steverguy
ID: 24315727
It was a combination of things - but the main thing was I didn't have my_mcl specified.
Working great now. Thanks!
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 22

Expert Comment

by:rascalpants
ID: 24316025
just a question, but why do you have...  gotoAndPlay(288);  in the spot it is in?

normally if you have the project wait until the thing gives you an error or it loads successfully, before you move on to another frame.


did you actually want this to be here...

mclListener.onLoadComplete = function(target_mc:MovieClip, status:Number):Void {
    trace("onLoadComplete: " + target_mc);
    gotoAndPlay(288);
};


and actually you should use onLoadInit instead of onLoadComplete, before you take any action.


rp / ZA
0
 
LVL 1

Author Comment

by:steverguy
ID: 24317318
Thanks for the input.  I guess I was just thinking it would run gotoAndPlay(288) after the external .swf was loaded... but putting it in the "onLoadComplete:" makes more sense.  

But are you suggesting i put it inside of onLoadInit?
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 24317550

yes...   onLoadComplete is the event that gets fired when the loading is completed...

onLoadInit is the event that gets fired when the loaded items is ready to interact with code.... this is when you set properties and such.


rp / ZA
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now