5 Replies Latest reply on Dec 27, 2006 10:43 AM by ntsiii

    popup

    jaimon_jaimon Level 1
      hi,
      is there any way to create popups not from a different mxml file, but that the popup would be just a container in the main file ??

      cheers
      Jaimon
        • 1. Re: popup
          Level 1
          You could create the popup object dynamically in actionscript. However, if you wanted to use mxml, I believe it has to be a separate file.

          What's your reasoning for not wanting to use a separate file?

          --Andy
          • 2. Re: popup
            ntsiii Level 3
            If you can use a standard class then you can pop-it up directly. I believe. I'll try this now to be sure and post an example.

            Tracy
            • 3. Re: popup
              ntsiii Level 3
              Yep, you can. I'll paste an example using a Text control below. I am sure you could also pop-up a container, like a panel or HBox, and even dynamically populate it using addChild. That'll be a later example though.

              Andy's question is a good one though. Except for trivial uses, an external file is much more flexible. What is you issue with an external file?

              Tracy
              • 4. Re: popup
                ntsiii Level 3
                Oh, another possibility: If your application uses absolute layout, you can include some container with any content, and then set its visible property to false. To "pop it up", just make it visible. This is not really a pop-up, but looks exactly like one.

                Put it at the end of the mxml, so it will display on top, or look into the depth manager.

                Tracy
                • 5. Re: popup
                  ntsiii Level 3
                  The example:
                  <?xml version="1.0" encoding="utf-8"?>
                  <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical" horizontalAlign="left">
                  <mx:Script><![CDATA[
                  import mx.managers.PopUpManager;
                  import mx.core.IFlexDisplayObject;
                  import mx.controls.Text;
                  private var _TextPopUp:Text;
                  private function showPopup():void
                  {
                  _TextPopUp = Text(PopUpManager.createPopUp(this, Text, false));
                  _TextPopUp.x = 100;
                  _TextPopUp.y = 100;
                  _TextPopUp.setStyle("fontSize",14);
                  _TextPopUp.text = "Test text in pop-up"
                  }//showPopup

                  private function closePopup():void
                  {
                  PopUpManager.removePopUp(_TextPopUp);
                  }//showPopup

                  ]]></mx:Script>
                  <mx:Button click="showPopup()" label="Pop Up Text box" />
                  <mx:Button click="closePopup()" label="Close Pop Up" />
                  </mx:Application>