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.’
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/