1 Reply Latest reply on Aug 14, 2007 3:45 AM by koushks

    run through UI Elements

    muzikathzi Level 1
      Hi
      I want to define change Eventlistener for all elements in a mxml component dynamically ( myUI.mxml).
      I tried this inside a class that extends canvas:

      _ui = new myUI()
      this.addChild(_ui);

      for(var i in _ui){
      _ui .addEventListener(Event.CHANGE, valueChanged);
      }

      but the "for in" loop doesn`t do anything.
      is there a way to run through all children/properties of a mxml component?

      thanks for help!
      muzi
        • 1. Re: run through UI Elements
          koushks
          _ui is a new UI component you created and added. You shouldn't be looping through it.

          You can use:
          this.getChildren() ;

          It returns an array of UI components that are children of your component. You can then loop through that array, cast each element as a 'DisplayObject' and add event listeners to it.

          Also helpful is:
          getChildAt(index:int);

          Returns a DisplayObject object at position 'index'.