# Dynamic Objects & Array Targeting

**URL:** <https://forum.kirupa.com/t/dynamic-objects-array-targeting/326493>\
**Category:** flash\
**Created:** [December 18, 2011, 5:04pm UTC](https://forum.kirupa.com/t/dynamic-objects-array-targeting/326493 "2011-12-18T17:04:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![VaLL](https://avatars.discourse-cdn.com/v4/letter/v/4491bb/32.png) [@VaLL](https://forum.kirupa.com/u/VaLL)\
**Post date:** [December 18, 2011, 5:04pm UTC](https://forum.kirupa.com/t/dynamic-objects-array-targeting/326493/1 "2011-12-18T17:04:25Z")

</div>

Hey,

I’m trying to create a movieclip from the library dynamically on a certain event and then being able to target one specific movieclip by name after they’ve been created. I’m having problems being able to target and have tried a tone of different approaches, I think I’m close but I’m getting the error ‘#1006: getChildByName is not a function.’

```auto

package {
	import flash.display.*;
	import flash.events.*;

	public class customClass extends MovieClip
	{

		var bobArray = new Array();
		var i:int = 1;
		
		public function init()
		{
			bt_test.addEventListener(MouseEvent.CLICK, creator);
			bt_test2.addEventListener(MouseEvent.CLICK, idBob);
		}
		public function creator(evt:MouseEvent)
		{
			var bob:Bob = new Bob();
			bob.name = "bob" + i;
			bob.x = Math.random() * stage.stageWidth;
			bob.y = Math.random() * stage.stageHeight;
			bob.alpha = 0.5;
			addChild(bob);
			i++;

			bobArray.push(bob.name);
		}
		public function idBob(evt:MouseEvent)
		{
			var target:DisplayObject = bobArray.getChildByName(String("bob" + i));
			trace(bobArray.getChildIndex("bob1")); 
			trace(bobArray)
		}
	}
}

```

The files are here if anyone can help, or offer an explanation would be much appreciated!  
[http://www.zumicreative.com/files/](http://www.zumicreative.com/files/)
