# Targeting mc's in an externally loaded swf

**URL:** <https://forum.kirupa.com/t/targeting-mcs-in-an-externally-loaded-swf/265293>\
**Category:** flash\
**Created:** [July 7, 2008, 2:55pm UTC](https://forum.kirupa.com/t/targeting-mcs-in-an-externally-loaded-swf/265293 "2008-07-07T14:55:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![eoj](https://avatars.discourse-cdn.com/v4/letter/e/85e7bf/32.png) [@eoj](https://forum.kirupa.com/u/eoj)\
**Post date:** [July 7, 2008, 2:55pm UTC](https://forum.kirupa.com/t/targeting-mcs-in-an-externally-loaded-swf/265293/1 "2008-07-07T14:55:22Z")

</div>

Hi,

I’m trying to target MC’s in a swf that im loading into my main swf in a holder mc called ‘holder’

In AS2 I would then target them by writing:

holder.myMc etc

but I can’t seem to target them properly in AS3 - If I ‘Debug \> List Object’ my swf & all it’s clips are there but the path is:

holder.instance9.myMc

Where’s does the instance9 Come from?

If i try to include instance9 when targeting it flash tells me its an ‘undefined property’ & doesnt load the swf as normal.

```auto
function startLoad() {
 var mLoader:Loader = new Loader();
 var mRequest:URLRequest = new URLRequest(sitePlan);
 mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
 mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
 mLoader.load(mRequest);
}
function onCompleteHandler(loadEvent:Event) {
  holder.addChild(loadEvent.currentTarget.content);
 
}
function onProgressHandler(mProgress:ProgressEvent) {
var percent:Number = Math.round((mProgress.bytesLoaded/mProgress.bytesTotal) * 100);
 txt.text = percent.toString() + '%';
 
}
startLoad();
 
holder.p301.addEventListener(MouseEvent.CLICK, showToolTip);
function showToolTip() {
 trace('Plot 301')
}

```

Any tips??  
Thanks in advance!

ps. I have just easked a similar question on the end of some one elses post but wanted to start a proper thread on it. Apologies if this is bad form!

---

<div class="post-metadata">

**Author:** ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)\
**Post date:** [July 7, 2008, 2:59pm UTC](https://forum.kirupa.com/t/targeting-mcs-in-an-externally-loaded-swf/265293/2 "2008-07-07T14:59:49Z")

</div>

instance9 is your loader class. The loader is actually a displayobject itself so there’s no need to use a ‘holder’. Just addchild the loader itself…

---

<div class="post-metadata">

**Author:** ![eoj](https://avatars.discourse-cdn.com/v4/letter/e/85e7bf/32.png) [@eoj](https://forum.kirupa.com/u/eoj)\
**Post date:** [July 7, 2008, 3:05pm UTC](https://forum.kirupa.com/t/targeting-mcs-in-an-externally-loaded-swf/265293/3 "2008-07-07T15:05:28Z")

</div>

ok - so:  
holder.addChild(loadEvent.currentTarget.content);  
becomes:  
addChild(loadEvent.currentTarget.content);  
??  
but how do I target the mc’s inside it?

---

<div class="post-metadata">

**Author:** ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)\
**Post date:** [July 7, 2008, 3:14pm UTC](https://forum.kirupa.com/t/targeting-mcs-in-an-externally-loaded-swf/265293/4 "2008-07-07T15:14:43Z")

</div>

just addChild(mLoader)

that’s enuf : )

Once it’s loaded you can access it’s children.

---

<div class="post-metadata">

**Author:** ![eoj](https://avatars.discourse-cdn.com/v4/letter/e/85e7bf/32.png) [@eoj](https://forum.kirupa.com/u/eoj)\
**Post date:** [July 7, 2008, 3:33pm UTC](https://forum.kirupa.com/t/targeting-mcs-in-an-externally-loaded-swf/265293/5 "2008-07-07T15:33:59Z")

</div>

oh.

im now typing in ‘get children’ in google and not getting quite what I wanted!!! lol.

oh man, I dont think this AS3 is sinking in very quick.

…how do ‘access it’s children’ ?

---

<div class="post-metadata">

**Author:** ![eoj](https://avatars.discourse-cdn.com/v4/letter/e/85e7bf/32.png) [@eoj](https://forum.kirupa.com/u/eoj)\
**Post date:** [July 7, 2008, 4:18pm UTC](https://forum.kirupa.com/t/targeting-mcs-in-an-externally-loaded-swf/265293/6 "2008-07-07T16:18:18Z")

</div>

I’ve tried to simplify it but I dont think Im getting it:

```auto

var request:URLRequest = new URLRequest("dalesview_work.swf");
var loader:Loader = new Loader()

loader.load(request);
addChild(loader);

loader.content.p301.addEventListener(MouseEvent.CLICK, showToolTip);
function showToolTip() {
	trace('Plot 301')
}

```

Basically Im tyring to load in a siteplan that has different plots in it - I’ve already been through the site plan & labelled each plot/movie clip as ‘p1’ ‘p2’… etc.

My main swf is just going to be the interface, loading in different siteplans - then showing tooltips with info over the diff plots.

I’ve got lots of XML stuff happening too & it’s the kind of thing i;ve done in AS2 but Im just not getting this child thing in AS3.

The above code returns an error: ‘access of possibly undefined property’ which I suppose is all the plots I’ve manually labelled?? Do i need to data type these in a loop?
