0 Replies Latest reply on Sep 27, 2010 9:48 AM by SiHoop

    I want a better way to target a child

    SiHoop Level 1

      I have a series of Canvas objects that each contain several other components: An image, a text field, another text field, etc.

      Each container is referenced in an array: containersArray.

      Each container is clickable and a reference to the clicked container is stored in selectedClip.

      When I click a container I want the text in one of the child text fields to change, but I'm having difficulty targeting that text field. The way I'm doing it at the moment is:

       

        editContent.addEventListener(Form.FORM_CHANGED, formChangedHandler)

        private function formChangedHandler(e:Event):void{

                for(var i:int=0;i<containersArray.length;i++){
                          if(containersArray[i]==selectedClip){
                              containersArray[i.getChildAt(3).text=e.currentTarget.formText.text;
                          }                   
                      }

      }

       

      This works, but it seems like a lot of work for such a simple activity. Is there a better way to target the text field inside the container or is the the correct approach?

      Thank you!