Good afternoon coders. I’m trying to reference a loader Object on the maintime line from within a MovieClip. More clearly, when I press one of my buttons (myCars or myVideos) I need my transition movieclip named container to play. Once the movieclip reaches a particular frame, I need the code in that frame to run.
First, here’s the code on the main timeline:
import flash.display.*;
var my_loader:Loader = new Loader();
addChild(my_loader);
var container:blue=new blue();
container.name = “myContainer”;
container.x=10.0;
container.y=74.0;
this.addChild(container);
var lastLoaded:String;
myVideos.addEventListener(MouseEvent.MOUSE_DOWN, loadTheBaby);
myCars.addEventListener(MouseEvent.MOUSE_DOWN, loadTheCars);
function loadTheBaby (e:MouseEvent):void{
if(e.currentTarget.name !=lastLoaded){
lastLoaded=e.currentTarget.name;
container.gotoAndPlay(“motivate”);
}
}
function loadTheCars (e:MouseEvent):void{
if(e.currentTarget.name !=lastLoaded){
lastLoaded=e.currentTarget.name;
container.gotoAndPlay(“motivate”);
}
}
**Now, here’s the code I need to run when the movieclip named container reaches a certain frame:
**
stop();
//lastLoaded=e.currentTarget.name;
my_loader.load(new URLRequest(lastLoaded+".swf"));
my_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
percent.text = Math.ceil(perc*100).toString();
}
function done(e:Event):void
{
removeChildAt(0);
percent = null;
addChild(my_loader);
gotoAndPlay(“closeup”);
}
Here are the error messages:
1120: Access of undefined property my_loader.
1120: Access of undefined property lastLoaded.
the variable lastLoaded is on the main timeline, and the loader Object my_loader is also on the main timeline. So, I believe I need to reference the loader Object and the lastLoaded variable on the main timeline from within a movieclip. I tried root.my_loader; I tried parent.my_loader to no avail. I even tried to put the loader object and the lastLoaded var in the movieclip and ran into a laundry list of errors. Is there a new way to access objects and variables on the main timeline from within a movieclip? Please steer me in the right diirection. Thanks for reading.
xFLASHSTUDENTx