1 Reply Latest reply on Oct 13, 2006 11:29 AM by ntsiii

    Add Children at runtime and questions related.

    leotemp Level 1
      Ok i have some basic conceptual questions maybe one of you wizards can answer. I am using the flex SDK, I am adding text components to my component at runtime, which works great. unfortunetly im stuck on a basic concept that relates to adding children.
      I can't seem to position the child, which i guess makes sense as how would flex know how to position it until after its in the parent, thats fine but i cant just try to change its position after its created from the same function as it might not exist yet so i need to do an event listener but i can't create the event listener either as the child still doesnt exist! ARRRGH! so i tried adding a "creation complete" to the text im creating and i get an error for doing that.. so in short, how do i position an added child if i can'y create an event listener and i can build an inline event trigger on a dynamically created child?

      I thought about maybe asking for a collection of children from the parent, but how would i know which child was the one i added? Here is an example function im using to add the text but thats as far as i have gotten.

      var textCount:Number= 1;
      private function newText():void {
      var newText:TextArea = new TextArea();
      newText.width= 96;
      newText.height= 96;
      newText.text= "Click to edit";
      newText.id= "textTome0"+ textCount.toString();
      hboxBookShelf.addChild(newText);
      }