1 Reply Latest reply on Apr 7, 2008 4:09 PM by slaingod

    Best way to find control in Application

    Brent Lamborn Level 2
      First week of flex and I am trying to determine the quickest most efficient way to find a control in my flex app. For instance I have this in my app:

      -> Canvas

      What would be the best way via ActionScript to get a handle to my ComboBox? I see the method this.getChildByName but it can apparently only see the 'first generation' of children and doesn't work in a recursive manner. Is there a way I can get ComboBox without any looping?

        • 1. Best way to find control in Application
          slaingod Level 1
          Generally you would just give your combobox an id="my_combo" and then you could use my_combo.visible = false pretty much anywhere. Only if you are dynamically generating your controls would you need to worry about recursing.

          (By anywhere, I mean in that particular mxml file. If it was say in a different component, you would need to traverse that component. Alternatively, if this is a dynamically generated control, you could simply create an Object to keep track of your controls as you create them:
          var controls:Object = new Object;

          var canvas:Canvas = new Canvas:
          canvas.id = 'my_canvas';

          controls[canvas.id] = canvas;

          then you could find it anywhere using:
          var my_control:UIComponent = controls['my_canvas'] as UIComonent;