# AS3 : How to target sub-MC of loaded .swf?

**URL:** <https://forum.kirupa.com/t/as3-how-to-target-sub-mc-of-loaded-swf/232052>\
**Category:** flash\
**Created:** [July 10, 2007, 8:43pm UTC](https://forum.kirupa.com/t/as3-how-to-target-sub-mc-of-loaded-swf/232052 "2007-07-10T20:43:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cpruitt](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@cpruitt](https://forum.kirupa.com/u/cpruitt)\
**Post date:** [July 10, 2007, 8:43pm UTC](https://forum.kirupa.com/t/as3-how-to-target-sub-mc-of-loaded-swf/232052/1 "2007-07-10T20:43:56Z")

</div>

Hey everyone. I’m new to AS3 and very… very lost (Last time I did much with flash was Flash 5).

Short version: I’m trying to load an external .swf from a URL and add event handlers to the movie clips (or it’s movie clips sub-MCs) on its stage. I can’t find a THING online on how to do this.

Details:

I’ve been tasked by my employer to build a simple control interface in flash, with just a few buttons to do things like display some info or images or maybe an associated MP3. I’ve written little test apps to do all of these individual things & managed to fake my way through.

But the sticking point is that I’m now trying to place all the UI controls into an external .swf, which I then load into the canvas by a URL. The goal is to be able to load it into a variable named, say, ‘private \_ui:MovieClip’ and then add event handlers to mivie clips within that by name like:

\_ui.someButton1.addEventListener(MouseEvent.MOUSE\_UP, handlerFunction1);  
\_ui.controlStrip.someButton2.addEventListener(MouseEvent.MOUSE\_UP, handlerFunction2);

The goal is that if we want to swap out the UI for a particular client, we just export a new .swf with all the correctly named MC instances & use the new URL to load the UI.

I seem to be able to load the .swf OK and trace the movie clips “Main Timeline” like so:

\_ui2.contentLoaderInfo.addEventListener(Event.COMPLETE , uiDidLoad);  
function uiDidLoad(evt:Event){  
trace(“UI2 LOADED”);  
if(\_ui2.content){  
addChild(\_ui2);  
trace(\_ui2.content); //–\> [object MovieClip]  
// Target the “ControlStrip” named instance on the loaded .swf’s main timeline  
trace(\_ui2.content.controlStrip); //–\> ERROR  
}  
}

Can anyone point me in the right direction here? I’ve spent hours making no headway on this. I think I’ve read half of adobe’s website so far. ☹

- Cliff

---

<div class="post-metadata">

**Author:** ![jnjcre8](https://avatars.discourse-cdn.com/v4/letter/j/b782af/32.png) [@jnjcre8](https://forum.kirupa.com/u/jnjcre8)\
**Post date:** [August 24, 2008, 10:13am UTC](https://forum.kirupa.com/t/as3-how-to-target-sub-mc-of-loaded-swf/232052/2 "2008-08-24T10:13:13Z")

</div>

I just ran across this post. I have almost a similar issue with targeting clips.

Here is what I am trying to do. I have a main.as(This is my Document class) that pulls in a video class(a bunch of functions). In the video class I have a player.swf load in it. I tell main.as(class) when it is done. Now at that point I am trying to target the header\_mc inside the player.swf from my main.as class. It seems if I call the header\_mc from within the video class it works but if I try to target it from main.as it is a no go. Is there a way to target clips inside a swf that was loaded from an imported class.

So just to help understand this.  
Main.as is the document class  
– imports video.as and adds new instance (public var my\_video:VideoClass = new VideoClass(“player.swf”))  
---- Inside video.as I load “player.swf” (player.swf contains a header\_mc.txt.text)  
Main.as is told that video.as and player.swf is done.  
in Main.as I am trying to target header\_mc.txt to add info in it. but so far I have had no luck.

Has anyone tried this and is this possible?

Thanks in advance for your help.  
–Jose
