1 Reply Latest reply on Aug 11, 2009 2:13 PM by Kenny Yates

    creationComplete event and Popup

    Zolotoj Level 3

      I am creating a popup window with the following code:

      var popupWindow:TitleWindow = new TitleWindow;  
      popupWindow = c.showPopupWindow(DisplayObject(FlexGlobals.topLevelApplication), runtimeQtag);
      popupWindow.addEventListener("creationComplete", setSelectedQtag);
      

       

      private function setSelectedQtag(event:Event):void
      {
      runtimeQtag(event.target).portalqtags.selectedIndex = 10; // object in runtimeQtag component
      } 
      

      and then I am trying to catch a creationComplete  event to set some object in runtimeQtag component.

      Can't do right after

      popupWindow = c.showPopupWindow(DisplayObject(FlexGlobals.topLevelApplication), runtimeQtag);

       

      because objects are not ready yet, or so I think.

       

      Any idea?

       

      Thanks

        • 1. Re: creationComplete event and Popup
          Kenny Yates

          The issue you are having is that Pop Up windows outside the Application "domain".

           

          I suggest you create a new "Event" inside your Pop Up Window item and on it's creation complete even you dispatch out an event using something like this.


          Inside your Pop Up MXML item

          <mx:Metadata>
              [Event("finishLoading", "flash.events.Event")]//This lets the compiler place this event into the event stream
          </mx:Metadata>


          <mx:Script>
              <![CDATA[


                  private function initMyPopUp():void
                  {
                          var doneEvt:Event = new Event("finishLoading", true);
                          Application.application.dispatchEvent(doneEvt);
                  }
                 
                
              ]]>
          </mx:Script>

           

          Then at your Application level you add this listener to your init function on creation complete (or wherever you need to):

           

          this.addEventListener("finishLoading", setSelectedQTag, false, 0, true);

           

          The reason you dispatch the event from the Application level is that Pop Ups live in the System Manager level (if memory servers me) so you should dispatch the event from Application level so no disconnects occur.

           

          That way your function responds AFTER the Pop Up has been created.

           

          HTH,

          Kenny Yates

          http://truitgroup.com/flexgenie