var swfToLoad:String = "your url here";
var holderMC:MovieClip();
var hLoad:Loader = new Loader();
function hSpotLoader():void {
var hURLReq:URLRequest=new URLRequest(swfToLoad);
hLoad.contentLoaderInfo.addEventListener(Event.INIT,swfLoadCompleteHandler);
hLoad.load(hURLReq);
hLoad.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,swfError);
trace("swf Loader");
}
//function to handle error if there's a problem loading the swf
function swfError(evt:IOErrorEvent):void {
trace("Could not load swf.");
}
//function to load when the swf is completely loaded.
function swfLoadCompleteHandler(evt:Event):void {
holderMC=MovieClip(hLoad.content);
this.addChild(holderMC);
}
Then you should be able to reference anything like this:
It's just the main-timeline,
if I type it like this:
var holderMC:MovieClip = new MovieClip();
it doesn't complain any more but it doesn't load anything either.
Do I really need to use your loading code?
Is there something about the simple loader (that works!) that I posted at first (see below) that means I can't access the MC's inside it?
Code:
var request:URLRequest = new URLRequest("content.swf");
var loader:Loader = new Loader();
loader.load(request);
addChild(loader);
At some point I'm going to use an advance loader such as the one you have (which has error checking and stuff), but right now I'm just trying to understand what syntax to use to access the movieclip inside it.
Using "hLoad.content" like you and tutorials suggest (or "loader.content" in my case) for some reason just reports back null, but that external file DOES have a movieclip inside it.
Wow thanks!
I'm suprised that it should need that because I thought it was a really simple thing to do, but there could be a whole concept that I'm not understanding here, so thanks alot for taking a look at the flash file.
var request:URLRequest
var loader:Loader = new Loader();
function loadIt():void {
request = new URLRequest("LoadingExternal-External.swf");
loader.load(request);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
addChild(loader);
}
loadIt();
var holderClip:MovieClip;
function loadComplete(evt:Event):void {
trace("done");
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadComplete);
holderClip = MovieClip(loader.content);
addChild(holderClip);
trace(holderClip.ExternalMC_mc.x);
}
//Now I want to access that movieclip from that external MC, here's some random things I've tried:
//trace(ExternalMC_mc.x); //Doesn't work.
//trace(loader.ExternalMC_mc.x); //Doesn't work.
//trace(loader.content.ExternalMC_mc.x); //Doesn't work.
I've tried it and it works! atm I don't really understand why ".content" works in this case and not in my old code, but I'm going to get to the bottom of it!