3 Replies Latest reply on Apr 11, 2009 8:19 AM by ergo_eleven

    Problem with PopUpManager.createPopUp()

    ParomitaDey15 Level 1
      The component is a TitleWindow component, but when I build and run it the widnow is not rendered in the browsers. But when I run the swf file from the bin folder directly it renders the popup window properly. I am using the following codes for the main application and the component.

      Application (TestPopupWin.mxml)
      --------------------------------------------------------------
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
      <mx:Script>
      <![CDATA[
      import mx.managers.PopUpManager;
      import mx.containers.TitleWindow;
      import mx.core.IFlexDisplayObject;

      public var helpWindow:IFlexDisplayObject;
      public function displayForm():void {
      var helpWindow:XPrefs1 =
      XPrefs1(PopUpManager.createPopUp(this, XPrefs1, false));
      // Add title to the title bar.
      helpWindow.title="Prefs";
      helpWindow.showCloseButton = true;
      // Make title bar slightly transparent.
      //helpWindow.setStyle("borderAlpha", 0.9);
      // Add a close button.
      // To close the container, your must also handle the close event.
      //helpWindow.showCloseButton=true;
      PopUpManager.centerPopUp(helpWindow);
      }
      ]]>
      </mx:Script>
      <mx:Button label="Verify" click="displayForm();" />
      </mx:Application>

      --------------------------------------------------------------

      Custom Title window component (XPrefs1.mxml)

      <?xml version="1.0" encoding="utf-8"?>
      <mx:TitleWindow xmlns:mx=" http://www.adobe.com/2006/mxml"
      showCloseButton="true" width="600" height="500" borderAlpha="1"
      creationComplete="doInit()" label="Prefs" backgroundColor="#DEDCE9">


      <mx:Script>
      <![CDATA[
      import mx.managers.PopUpManager;

      private function doInit():void {
      // Center the TitleWindow container over the control that created it.
      PopUpManager.centerPopUp(this);
      }

      private function removeMe():void {
      PopUpManager.removePopUp(this);
      }

      ]]>
      </mx:Script>

      <mx:Label text="Hello"/>
      <mx:HBox width="100%">
      <mx:Spacer width="500">

      </mx:Spacer>
      <mx:Button label="Close" click="removeMe()"/>
      </mx:HBox>


      <mx:TabNavigator label="Prefs" x="10" y="10" width="100%" height="100%">
      <mx:Canvas label="Personal" width="100%" height="100%">
      <mx:Label x="10" y="10" text="Email Address:"/>
      <mx:TextInput x="121" y="8" width="255"/>
      <mx:Label x="10" y="36" text="First Name:"/>
      <mx:TextInput x="121" y="34" width="255"/>
      <mx:Label x="10" y="64" text="Last Name:"/>
      <mx:TextInput x="121" y="62" width="255"/>
      <mx:Label x="10" y="91" text="Company:"/>
      <mx:TextInput x="121" y="89" width="255"/>
      <mx:Label x="10" y="117" text="Position:"/>
      <mx:TextInput x="121" y="115"/>
      <mx:Label x="10" y="143" text="Phone:"/>
      <mx:TextInput x="121" y="141"/>
      <mx:Label x="10" y="170" text="Fax:"/>
      <mx:TextInput x="121" y="168"/>
      <mx:TextInput x="121" y="194"/>
      <mx:TextInput x="121" y="220"/>
      <mx:TextInput x="121" y="246"/>
      </mx:Canvas>
      <mx:Canvas label="Change Password" width="100%" height="100%">
      </mx:Canvas>
      <mx:Canvas label="Notification" width="100%" height="100%">
      </mx:Canvas>
      </mx:TabNavigator>

      </mx:TitleWindow>

      ---------------------------------------------------------------------------------

      Please help me.

      Regards,
      Paromita
        • 1. Re: Problem with PopUpManager.createPopUp()
          mac_martine Level 1
          Your code works perfectly fine for me.
          When I run TestPopupWin.mxml I get a button that opens the TitleWindow when it's clicked on.
          Are you saying that when you click on the button, nothing happens?
          • 2. Re: Problem with PopUpManager.createPopUp()
            ParomitaDey15 Level 1
            Thanks for your response.

            Yes exactly, thats the problem. When I click on the button nothing happens. If the popup mode in the createPopUp() method is made modal, then on clicking the button the browser window greys out and nothing happens.

            Do I need to make any particular settings etc. before running the code or any specific browser setting is required?

            Please help and advise.

            Thanks and Regards,

            Paromita
            • 3. Re: Problem with PopUpManager.createPopUp()
              ergo_eleven

              Paromita, when you make application for Flash Player - forget about browser and its settings. This is the very pretty thing of flash!

              You code works well. If you don't see popup window in real application, I guess you have another problem that doesn't relate with PopUpManager.

              I can give only advise how to elegant create popups:

               

              var helpWindow : XPrefs1 = new XPrefs1();
              helpWindow.title = "Prefs";
              helpWindow.showCloseButton = true;
              
              PopUpManager.addPopUp(helpWindow, this, true);
              PopUpManager.centerPopUp(helpWindow);