View Full Version : [AS3] Working with imported components

12-15-2009, 05:44 PM
Hello everyone,

I'm new in this forum as you can see (first post :D), and in need of help in a matter regarding imported components.
The problem is that I'm working in a flash website in AS3 (recently migrated from AS2), and I'm having trouble with the Text Input component. I just want to import a Text Imput component into a movieclip located in the Main timeline, and then store it in an Object Variable or push it to an Array.

To do something like this in AS2, with a movieclip in the library I would do:

attachMovie("img", "img"+i, this.getNextHighestDepth());

But, can I apply this same principle in AS3 when importing a component instance? I tried it like this:

counter++; //A number variable that will count the instances of the component in the stage
var imgTxt:TextInput = new TextInput();
form1.addChild(imgTxt); //form1 is my movieclip in the main timeline
imgTxt.name = "imgTxt"+counter;
myArray.push(form1.imgTxt.name); /*Now, my problem lies here because this line returns me an error. Is there some easy way to do what
I'm trying to do here? I also tried myArray.push(form1[imgTxt.name]), wich lead to an error either*/

12-17-2009, 06:58 PM
Come on guys, can't someone please help me out here? Most of you guys no more than me about this stuff. The absence of this["string"+int] in AS3 is blocking all my School projects.

12-17-2009, 07:40 PM
I finally found I have to use getChildByName("string"+int). Was it to difficult to post this here?