# How to control nested MC created with addChild?

**URL:** <https://forum.kirupa.com/t/how-to-control-nested-mc-created-with-addchild/318438>\
**Category:** Uncategorized\
**Created:** [January 20, 2011, 8:06am UTC](https://forum.kirupa.com/t/how-to-control-nested-mc-created-with-addchild/318438 "2011-01-20T08:06:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![apricota](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@apricota](https://forum.kirupa.com/u/apricota)\
**Post date:** [January 20, 2011, 8:06am UTC](https://forum.kirupa.com/t/how-to-control-nested-mc-created-with-addchild/318438/1 "2011-01-20T08:06:27Z")

</div>

i tried a lot but couldn’t fix the problem…

why is the following code is not working?  
(please see fla too)…

thanks a lot!

the code:

```auto

/*
i tried to create nested movieClip, and then to add it eventListener, and to it's nested mc too.
i can't control neither the "mySquare_mc" MovieClip, and neither it's nested MovieClip ("circle_mc")
while i'm trying to control the inner MC i get this Error:
"TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at example_fla::MainTimeline/moveIt()"
	
what can be the problem?!

*/

import flash.events.MouseEvent;

var mySquare_mc:MovieClip = new sq();
mySquare_mc.name = "sq";
mySquare_mc.x = 20;
mySquare_mc.y = 20;
addChild(mySquare_mc);

var circle_mc:MovieClip = new cc();
circle_mc.x = 10;
circle_mc.y = 10;
mySquare_mc.addChild(circle_mc);

mySquare_mc.addEventListener(MouseEvent.CLICK,moveIt);

function moveIt(event:MouseEvent){
	mySquare_mc.x+=50;
	mySquare_mc.circle_mc.alpha-=0.1;
}

//this is not working too:

/*function moveIt(event:MouseEvent){
	mySquare_mc.x+=50;
	getChildByName("mySquare_mc").getChildByName("circle_mc").alpha-=0.1;
}*/

```
