This content has been marked as final. Show 5 replies
loading a movie clip in AS3 is done with the Loader Class.
Modified example directly from CS3 Help...
var ldr:Loader = new Loader();
var url:String = " http://www.unknown.example.com/content.swf";
var urlReq:URLRequest = new URLRequest(url);
I'd recommend getting your hands on Essential ActionScript 3.0 and the ActionScript 3 Cookbook. I remember this topic coming up in the cookbook. I'm going to check my code at home tonight. I am pretty sure I used a similar tactic when I was updating an image reel I did in Flash 8 (AS2).
Thanks. I am not having any problem at all with loading the .swf, I just can't seem to target anything inside of it. It seems like [_ui2.content], because it is a movie clip, should respond to .getChildAt() or getChildByName() but both of those generate errors saying that [_ui2.content] is a DisplayObject, which I guess means it's not a DisplayObjectContainer. THat's confusing to me because I thought the API docs said that MovieClip inherits from DisplayObjectContainer.
(I'm not looking at my code right now so some of the method/class names I'm using might be slightly wrong here but I double checked them all in my code)
If you have any further insight on how to target items within the loaded .swf I'd be really grateful. I'll check out the books & see if they offer any insight.
you can reference the main timeline of your loaded swf via the content property of your loader (say ldr) AFTER loading is complete.
you then need to cast that object as a MovieClip or the flash compiler has concerns. if you have an object on the main timeline of your loaded swf with instance name btn, you can use the following to add a mouse handler to it:
Originally posted by: kglad
you then need to cast that object as a MovieClip or the flash compiler has concerns.
I discovered this yesterday after a *lot* of trial and error. Everything seems to work fine when using:
ldr.content as MovieClip;
I'm kind of surprised that's not documented somewhat clearly, but I suppose it might be something that's obvious if you know AS well enough. I am trying to learn as much as I can as I go but don't my timeline doesn't really permit a while lot of time for learning from the ground up.