Controlling Loader

:vader: Hello,
I hope this is a simple question.
I have a class file that is loading a SWF file.
I cannot seem to access the loaded movie from the document class? What am I missing?


import extransLoader;
var newExTransLoader=new extransLoader;
newExTransLoader.nextMovie="movie1.swf";
newExTransLoader.setexLoader();
addChild(newExTransLoader);

button1.addEventListener(MouseEvent.CLICK, clickButton);


function clickButton(event:MouseEvent):void {
if(newExTransLoader.nextMovie!="movie1.swf"){
    newExTransLoader.nextMovie="movie1.swf";
    trace(newExTransLoader.nextMovie);
    newExTransLoader.gotoAndPlay("outro");//<---------This is the line in question.
}
} 

Any help would be greatly appreciated!!!

You’re using the Loader class? To access the swf in a Loader variable you use loader.content where content is the DisplayObject. Because content is a DisplayObject you can’t access any properties that aren’t defined in DisplayObject. You can cast it to the class that you are working with, like MovieClip(loader.content) and then use functions like gotoAndPlay, but if you have objects in the swf you wouldn’t be able to access them because they aren’t defined anywhere, and loader has no way of knowing what they are. You could access them manually by doing loader.content[“variable name”] but this is messy because the compiler wont do any compile time checking to make sure the variable exists, so if you mistype you will get run time errors. Alternately you could make a class for that particular swf and typecast to that, but I’m not sure if that would work.