3 Replies Latest reply on Jan 5, 2010 9:38 PM by jfizer

    Calling functions in a component before the component UI is used?

    jfizer Level 1

      I know this has been asked before, in fact I'm sure I've had this problem and resolved it in the past. However, I can't recall the solution off hand.

       

      I have a component, which contains a publich function and data. The component has a UI which can be loaded by another function call. Loading the UI works fine, and after its been loaded (and close) calling the first function works fine. However, before hte UI has been loaded calling the function does nothing.

       

      Any thoughts?

        • 1. Re: Calling functions in a component before the component UI is used?
          Gregory Lafrance Level 6

          Load the UI earlier but set the visible and includeInLayout properties to the component to false.

           

          Then in the function call that used to load the UI, just set those properties to true.

           

          If this post answers your question or helps, please mark it as such.


          Greg Lafrance - Flex 2 and 3 ACE certified

          www.ChikaraDev.com

          Flex / AIR Development, Training, and Support Services

          • 2. Re: Calling functions in a component before the component UI is used?
            jfizer Level 1

            So order of operations question on that. I build the UI elements in the on initialization function for the component and then display it with another function call. Basically I have the UI designed in MXML and then assign it as a child to a new Panel() object created in the init' function. This is then displayed using the mx.managers.PopUpManager.addPopUp() function called from a publicly declared function in the component. For the life of me I can not think why the display function works without any problems but the secondary function (a data filter-function) only works after the UI has been displayed.

             

            Nothing in the filter funciton references any of the UI elements directly. But what would be the order of precdence for initilizing the UI before hand? Would I add that code to the initialize function or creationComplete?

            • 3. Re: Calling functions in a component before the component UI is used?
              jfizer Level 1

              So I went ahead and added the code to display the UI to the creationComplete function. If the UI is displayed and the user closes it, the subsequent call to the filter function works. However, if I close it in code, it fails.


              Note that the failure is that it does nothing. There is no error message and any alerts I put in the function are not triggered.

               

              I feel grey hairs comming on from this...