Solved

Actionscript 2 LoadMovie

Posted on 2009-05-05
6
1,031 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Text To Speech Reader For Adobe Flash Pages 4 935
Adobe flash player fails to install 12 313
bandwidth 5 76
Play RTMP without Flash 3 644
This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

830 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