2 Replies Latest reply on Feb 20, 2012 10:41 PM by Flex harUI

    Trouble with popup not initialized until addPopUp is called

    Jay_Ds

      I am having troubles with initialization.  I have a class given below.  I new() it at the start and use PopUpManager.addPopUp to display it.

       

      My problem is that the line query:QueryWIthOption id="filterComp" is a class with a lot of variables.  However, if I try to set any of them before I call addPopUp, it doesn't work because filterComp is null.

       

      I therefore either need to initialize filterComp earlier, store the data until AddToPopup is called, or change the way I am implementing this.  If I store the data in variables, I have to add a whole bunch either to the class below or to the calling class.

       

      Doing this once is managable, but I have other similar examples with a similar problem. This code was flex 3 before where filterComp was always initialized.

       

      Is there any good way to do this?  I guess I am interested in both the way to do this in a minimal way, and what is the best way to code to avoid this issue (if I am adding something new in the future).

      Jay

       

      QueryWithOptionWrapper class:

       

      <?xml version="1.0" encoding="utf-8"?>

      <mx:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"

                      xmlns:s="library://ns.adobe.com/flex/spark"

                      xmlns:mx="library://ns.adobe.com/flex/mx"

                      xmlns:query="com.niksun.dashboard.components.query.*">

          <fx:Script>

              <![CDATA[

                  import com.niksun.common.managers.ResourceManager;           

              ]]>

          </fx:Script>

          <mx:VBox horizontalAlign="center" width="100%" height="100%" paddingTop="5">

              <query:QueryWithOption id="filterComp" showFilter="true"/>

              <mx:HBox width="100%" horizontalAlign="center" horizontalGap="10">

                  <!-- enabled="{!ModelLocator.getInstance().progress}" -->

                  <mx:Button id="update" label="{ResourceManager.getString('Update')}"

                             horizontalCenter="0"/>

                  <mx:Button id="reset" label="{ResourceManager.getString('Reset')}"/>

                  <mx:Button id="cancel" label="{ResourceManager.getString('Cancel')}"/>

              </mx:HBox>

          </mx:VBox>

      </mx:TitleWindow>