Solved

Actionscript 2 LoadMovie

Posted on 2009-05-05
6
1,000 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
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 how to record live broadcast.

707 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

11 Experts available now in Live!

Get 1:1 Help Now