Using Movie Clips from a loaded swf

When you need to load a movie clip in a loaded swf how do you do it? then you want to use the clips in the loaded movie your swf.
Every swf can be loaded in three different ways , while you can use the code included in a movie clip this also allows you to use the visual assets in the fla’s library . to make this work you need two swfs on your base swf with this code in the main timeline

Yes I know it should a class but we’re just trying to learn the basics of the code

In our second swf named s_1.fla is a movie clip in the liibrary named C1 set to dispatch

var _loader:Loader
var info:LoaderInfo
_loader = new Loader(); //create a loader
info= _loader.contentLoaderInfo;//checks the actual contet of the object not just the loader we are splitting things up here
info.addEventListener(Event.COMPLETE, onInit, false, 0, true)// add a listener for the init event that fires when all the assets of the loaded swf is available to you

function onInit (e:Event) {
// e is the intit event it means the swf is ready to be used
// target is the swfs contentloaderInfo every swf has an applicationDomain, a loaded swfs domain by default is the main movies child. hasDefinition is a method it’s asking if in this application is there a Movie CLip named “c1”
trace(“head exists: ” +“c1”) );
// okay so are definition exists but we need to set it up so we can use is as a constructor and make it into a class we do that by using the keyword as types the “c1 as a Class so we can pu tit into a variable and then make a new instance of the it
var head:Class =“c1”) as Class;
var p = new head()
//make a new instance and stick it on the stage

// actually load the swf
_loader.load(new URLRequest(“s_1.swf”))

You should be able to past this code into a main timeline and it will run once you make the second swf named s_1.swf with the movie clip in it.

One reply on “Using Movie Clips from a loaded swf”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.