Controlling movie clips on the stage

I loaded a movie clip like this:
// load Home Movie
var loader:Loader = new Loader();
var request:URLRequest = new URLRequest(“home.swf”);
loader.load(request);
// use addChild() to use your movieclip as the Loader object’s container:
container.addChild(loader);

Now, I want to tell that movie clip to do something so I put this:
// play the closing section of the MC inside of the container
container.gotoAndPlay(“closing”);

And, of course it didn’t work in actionscript 3!!!

Any ideas?
:m:

I’m a noob, so apologies in advance if this doesn’t work, but your question prompted me to read a chapter in a book that I’ve been meaning to get to grips with, and it seems to work OK.

Try this:

stop();

import flash.display.*;

var loader:Loader = new Loader();
var request:URLRequest = new URLRequest("home.swf");
loader.load(request);


// when the swf has finished loading, we want to run the 'swfLoaded' function
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,swfLoaded);


// this runs when the swf has finished loading
function swfLoaded(myEvent:Event):void
{
    // put the swf on the stage
    stage.addChild(loader);
    
    // create a movie clip we can control
    var myContent:MovieClip = myEvent.target.content;

    // play the bit you want
    myContent.gotoAndStop("closing");
    
    // change the swf's position (but only if you want to ...)
    myContent.x = 120;
    myContent.y = 90;
}

Like I say, I’m a noob, so there may be a more elegant way to do this.