14 Replies Latest reply on Jun 10, 2009 9:24 PM by _Natasha_

    Call child window

    xpad

      I like to call child window as a pop up window from main window

      i created 1 button by clicking that button it should invoke child window with all components in that child window,

      I created child window as different flex project, could any one help me in writing code to call?

        • 1. Re: Call child window
          _Natasha_ Level 4

          Hi,

           

          <Script>

          <![CDATA[

          private function openChildWindow():void

          {

          var _childWindow:ChildWindowFileName = ChildWindowFileName(PopUpManager.createPopUp(this, ChildWindowFileName, true));

           

          _childWindow.addEventListener(CloseEvent.CLOSE, onCloseChildWindow);

          // call any other functions ... and listeners

          }

           

          // handler for closing window

          private function onCloseChildWindow(event:CloseEvent):void

          {

          PopUpManager.removePopUp(IFlexDisplayObject(event.target));

          }

          ]]>

          <mx:Button text="open child window" click="openChildWindow()"/>

          • 2. Re: Call child window
            xpad1

            May I know what is Target in following code

             

            <Script>

            <![CDATA[

            private function openChildWindow():void

            {

            var _childWindow:ChildWindowFileName = ChildWindowFileName(PopUpManager.createPopUp(this, ChildWindowFileName, true));

            _childWindow.addEventListener(CloseEvent.CLOSE, onCloseChildWindow);

            // call any other functions ... and listeners

            }

             

            // handler for closing window

            private function onCloseChildWindow(event:CloseEvent):void

            {

            PopUpManager.removePopUp(IFlexDisplayObject(event.target));

            }

            ]]>

            <mx:Button text="open child window" click="openChildWindow()"/>

            • 3. Re: Call child window
              xpad1 Level 1

              Following is the code,May i know where am I going wrong?

               

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

              <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"

              backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#B9B9C1, #CDCDD9]" width="796" borderColor="#CDE2F0">

               

                  <mx:Script>

                      <![CDATA[

                     

                            private function openChildWindow():void

                               {

                                  var _pov:ChildWindowFileName = ChildWindowFileName(PopUpManager.createPopUp(this, ChildWindowFileName, true));

                                    _pov.addEventListener(CloseEvent.CLOSE, onCloseChildWindow);

               

               

              // call any other functions ... and listeners

                               }

               

               

              // handler for closing window

                            private function onCloseChildWindow(event:CloseEvent):void {

                                 PopUpManager.removePopUp(mx.core.IFlexDisplayObject(event.Target));

                               }

                       ]]>

               

                  </mx:Script>

              • 4. Re: Call child window
                _Natasha_ Level 4

                What's a problem? What you've seen?

                • 5. Re: Call child window
                  xpad1 Level 1

                  ndGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#B9B9C1, #CDCDD9]" width="796" borderColor="#CDE2F0">

                   

                      <mx:Script>

                          <![CDATA[

                         

                                private function openChildWindow():void

                                   {

                                      var _pov:ChildWindowFileName = ChildWindowFileName(PopUpManager.createPopUp(this, ChildWindowFileName, true));

                                        _pov.addEventListener(CloseEvent.CLOSE, onCloseChildWindow);

                   

                   

                  // call any other functions ... and listeners

                                   }

                   

                   

                  // handler for closing window

                                    private function _pov.onCloseChildWindow(event:CloseEvent):void {

                                    PopUpManager.removePopUp(IFlexDisplayObject(event.target));

                                  }

                           ]]>

                   

                      </mx:Script>

                   

                   

                  Getting error at private function _pov.onCloseChildWindow(event:CloseEvent):void {

                   

                  1084 - Syntax error - expecting leftparen before dot

                  • 6. Re: Call child window
                    _Natasha_ Level 4

                    You can't use dots for functions names.

                    Bolded names should be equal.

                    <mx:Script>

                            <![CDATA[

                          

                                  private function openChildWindow():void

                                     {

                                        var _pov:ChildWindowFileName = ChildWindowFileName(PopUpManager.createPopUp(this, ChildWindowFileName, true));

                                          _pov.addEventListener(CloseEvent.CLOSE, onCloseChildWindow);

                     

                     

                    // call any other functions ... and listeners

                                     }

                     

                     

                    // handler for closing window

                                      private function onCloseChildWindow(event:CloseEvent):void {

                                      PopUpManager.removePopUp(IFlexDisplayObject(event.target));

                                    }

                             ]]>

                     

                        </mx:Script>

                    • 7. Re: Call child window
                      xpad1 Level 1

                      Natasha,

                       

                      Thanks for your reply

                      I am going to include code for main window and child window

                      Following is the code for main window, I want to call child window by clicking button in main window.

                      Could you please help me in this, greatly appreciated your help

                       

                      <mx:FormHeading x="311" y="10" label="VITALS " color="#D12448" fontWeight="bold" textDecoration="underline" fontFamily="Times New Roman" fontSize="20"/>

                      <mx:Panel x="20" y="411" width="723" height="114" layout="absolute" title="Date/Time Vital Value Entered By Purpose Of Visit" fontFamily="Times New Roman" fontSize="12" color="#020007" backgroundColor="#F9F9FB" borderColor="#6B84EE" themeColor="#6467E2">

                      </mx:Panel>

                      <mx:Button x="351" y="533" label="Exit" color="#F4240E" fontFamily="Arial"/>

                      <mx:Text x="71" y="383" text="Latest Vitals for this Patient" fontFamily="Times New Roman" color="#090001" fontSize="14" fontWeight="bold"/>

                      <mx:Panel x="20" y="47" width="723" height="328" layout="absolute" color="#0C0C0C" backgroundColor="#F6F7FB" borderColor="#6484EE" themeColor="#6467E2">

                      <mx:title><![CDATA[Patient, One ]]></mx:title>

                      <mx:Label x="32" y="49" text="Temperature" color="#000207" fontFamily="Arial" fontSize="13"/>

                      <mx:TextInput x="273" y="50" width="87"/>

                      <mx:Label x="32" y="79" text="Pulse" color="#000108" fontFamily="Verdana" fontSize="12"/>

                      <mx:Label x="33" y="167" text="Respiration" color="#010006" fontFamily="Verdana" fontSize="12"/>

                      <mx:Label x="32" y="108" text="Pain" color="#000900" fontSize="12"/>

                      <mx:Label x="32" y="137" text="Blood Pressure" color="#000108" fontSize="12"/>

                      <mx:Label x="33" y="197" text="Height" color="#000003" fontSize="12"/>

                      <mx:TextInput x="273" y="79" width="87"/>

                      <mx:TextInput x="273" y="109" width="87"/>

                      <mx:TextInput x="273" y="137" width="87"/>

                      <mx:TextInput x="273" y="167" width="87"/>

                      <mx:TextInput x="273" y="197" width="87"/>

                      <mx:Label x="34" y="228" text="Weight" color="#000007" fontSize="12"/>

                      <mx:TextInput x="273" y="226" width="87"/>

                      <mx:FormHeading x="32" y="22" label="VITAL" color="#050001" textDecoration="underline"/>

                      <mx:FormHeading x="273" y="22" label="VALUE" color="#060000" textDecoration="underline"/>

                      <mx:Button x="256" y="256" label="Save" color="#F42C11" fontFamily="Arial" fontWeight="bold"/>

                      <mx:Button x="334" y="256" label="Edit" color="#F42C11"/>

                      <mx:Button x="492" y="167" label="Purpose of Visit"

                      click="openChildWindow()"/>

                      <mx:TextInput x="-1" y="-1" width="714" backgroundColor="#EEEBEB">

                      <mx:text><![CDATA[ Patient, One 123-65-9987 01/01/1947 Date / Time]]></mx:text>

                      </mx:TextInput>

                      </mx:Panel>

                      <mx:Button x="242" y="535" label="Save And Exit" fontFamily="Arial" fontSize="9" width="93" color="#F4160B" fontWeight="bold"/>

                       

                       

                      </mx:Application>

                       

                       

                      Following is the code for child window

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

                      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

                       

                      <mx:TitleWindow x="102.5" y="28" width="730" height="373" layout="absolute" title="Visit Purpose " backgroundColor="#F6F7FB" showCloseButton="true" verticalAlign="top" fontWeight="bold" borderColor="#6B84EE" themeColor="#6467E2">

                      <mx:Label x="88" y="45" height="22" text="Purpose"/>

                      <mx:RadioButtonGroup id="radiogroup1"/>

                      <mx:RadioButton x="147" y="28" label="Routine" groupName="radiogroup1"/>

                      <mx:RadioButtonGroup id="radiogroup2"/>

                      <mx:Label x="88" y="217" text="Date of Onset"/>

                      <mx:TextInput x="195" y="215" width="120"/>

                      <mx:TextArea x="192" y="133" height="70" width="333"/>

                      <mx:Label x="107" y="171" text="Symptoms"/>

                      <mx:Button x="282" y="267" label="Save "/>

                      <mx:Button x="359" y="267" label="Exit"/>

                      <mx:Button x="432" y="267" label="Edit"/>

                      <mx:Label x="88" y="95" text="Purpose of Visit"/>

                      <mx:TextInput x="-1" y="-1" width="768" backgroundColor="#EEEBEB">

                      <mx:text><![CDATA[ Patient, One 123-65-9987 01/01/1947 Date / Time]]></mx:text>

                      </mx:TextInput>

                      <mx:TextArea x="192" y="81" width="315"/>

                      <mx:RadioButton x="148" y="50" label="Sick"/>

                      </mx:TitleWindow>

                      </mx:Application

                       

                      • 8. Re: Call child window
                        xpad1 Level 1

                        Natasha,

                         

                        Thanks for your reply

                        I am going to include code for main window and child window

                        Following is the code for main window, I want to call child window by clicking button in main window.

                        Could you please help me in this, greatly appreciated your help

                         

                        <mx:FormHeading x="311" y="10" label="VITALS " color="#D12448" fontWeight="bold" textDecoration="underline" fontFamily="Times New Roman" fontSize="20"/>

                        <mx:Panel x="20" y="411" width="723" height="114" layout="absolute" title="Date/Time Vital Value Entered By Purpose Of Visit" fontFamily="Times New Roman" fontSize="12" color="#020007" backgroundColor="#F9F9FB" borderColor="#6B84EE" themeColor="#6467E2">

                        </mx:Panel>

                        <mx:Button x="351" y="533" label="Exit" color="#F4240E" fontFamily="Arial"/>

                        <mx:Text x="71" y="383" text="Latest Vitals for this Patient" fontFamily="Times New Roman" color="#090001" fontSize="14" fontWeight="bold"/>

                        <mx:Panel x="20" y="47" width="723" height="328" layout="absolute" color="#0C0C0C" backgroundColor="#F6F7FB" borderColor="#6484EE" themeColor="#6467E2">

                        <mx:title><![CDATA[Patient, One ]]></mx:title>

                        <mx:Label x="32" y="49" text="Temperature" color="#000207" fontFamily="Arial" fontSize="13"/>

                        <mx:TextInput x="273" y="50" width="87"/>

                        <mx:Label x="32" y="79" text="Pulse" color="#000108" fontFamily="Verdana" fontSize="12"/>

                        <mx:Label x="33" y="167" text="Respiration" color="#010006" fontFamily="Verdana" fontSize="12"/>

                        <mx:Label x="32" y="108" text="Pain" color="#000900" fontSize="12"/>

                        <mx:Label x="32" y="137" text="Blood Pressure" color="#000108" fontSize="12"/>

                        <mx:Label x="33" y="197" text="Height" color="#000003" fontSize="12"/>

                        <mx:TextInput x="273" y="79" width="87"/>

                        <mx:TextInput x="273" y="109" width="87"/>

                        <mx:TextInput x="273" y="137" width="87"/>

                        <mx:TextInput x="273" y="167" width="87"/>

                        <mx:TextInput x="273" y="197" width="87"/>

                        <mx:Label x="34" y="228" text="Weight" color="#000007" fontSize="12"/>

                        <mx:TextInput x="273" y="226" width="87"/>

                        <mx:FormHeading x="32" y="22" label="VITAL" color="#050001" textDecoration="underline"/>

                        <mx:FormHeading x="273" y="22" label="VALUE" color="#060000" textDecoration="underline"/>

                        <mx:Button x="256" y="256" label="Save" color="#F42C11" fontFamily="Arial" fontWeight="bold"/>

                        <mx:Button x="334" y="256" label="Edit" color="#F42C11"/>

                        <mx:Button x="492" y="167" label="Purpose of Visit"

                        click="openChildWindow()"/>

                        <mx:TextInput x="-1" y="-1" width="714" backgroundColor="#EEEBEB">

                        <mx:text><![CDATA[ Patient, One 123-65-9987 01/01/1947 Date / Time]]></mx:text>

                        </mx:TextInput>

                        </mx:Panel>

                        <mx:Button x="242" y="535" label="Save And Exit" fontFamily="Arial" fontSize="9" width="93" color="#F4160B" fontWeight="bold"/>

                         

                         

                        </mx:Application>

                         

                         

                        Following is the code for child window

                         

                         

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

                        <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

                         

                        <mx:TitleWindow x="102.5" y="28" width="730" height="373" layout="absolute" title="Visit Purpose " backgroundColor="#F6F7FB" showCloseButton="true" verticalAlign="top" fontWeight="bold" borderColor="#6B84EE" themeColor="#6467E2">

                        <mx:Label x="88" y="45" height="22" text="Purpose"/>

                        <mx:RadioButtonGroup id="radiogroup1"/>

                        <mx:RadioButton x="147" y="28" label="Routine" groupName="radiogroup1"/>

                        <mx:RadioButtonGroup id="radiogroup2"/>

                        <mx:Label x="88" y="217" text="Date of Onset"/>

                        <mx:TextInput x="195" y="215" width="120"/>

                        <mx:TextArea x="192" y="133" height="70" width="333"/>

                        <mx:Label x="107" y="171" text="Symptoms"/>

                        <mx:Button x="282" y="267" label="Save "/>

                        <mx:Button x="359" y="267" label="Exit"/>

                        <mx:Button x="432" y="267" label="Edit"/>

                        <mx:Label x="88" y="95" text="Purpose of Visit"/>

                        <mx:TextInput x="-1" y="-1" width="768" backgroundColor="#EEEBEB">

                        <mx:text><![CDATA[ Patient, One 123-65-9987 01/01/1947 Date / Time]]></mx:text>

                        </mx:TextInput>

                        <mx:TextArea x="192" y="81" width="315"/>

                        <mx:RadioButton x="148" y="50" label="Sick"/>

                        </mx:TitleWindow>

                        </mx:Application

                        • 9. Re: Call child window
                          _Natasha_ Level 4

                          This should be like this

                           

                          For main application:

                          <mx:Application ...>

                          <mx:Script>

                                  <![CDATA[

                               

                                        private function openChildWindow():void

                                           {

                                              var _pov:ChildWindowFileName = ChildWindowFileName(PopUpManager.createPopUp(this, ChildWindowFileName, true));

                                                _pov.addEventListener(CloseEvent.CLOSE, onCloseChildWindow);


                                           }



                          // handler for closing window

                                            private function onCloseChildWindow(event:CloseEvent):void {

                                            PopUpManager.removePopUp(IFlexDisplayObject(event.target));

                                          }

                                   ]]>


                              </mx:Script>

                          <!-- YOUR CODE FROM MAIN WINDOW STARTS HERE -->

                           

                          </mx:Application>

                          ChildWindowFileName should be the name of the file with child window without mxml.

                           

                          Also there is a error in child window.

                          It should not be an application. When you create a child window it should be a MXML Component extended TitleWindow, not mxml aplliction with titleWindow inside. Should look like

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

                          <mx:TitleWindow x="102.5" y="28" width="730" xmlns:mx="http://www.adobe.com/2006/mxml" height="373" layout="absolute" title="Visit Purpose " backgroundColor="#F6F7FB" showCloseButton="true" verticalAlign="top" fontWeight="bold" borderColor="#6B84EE" themeColor="#6467E2">

                          <mx:Label x="88" y="45" height="22" text="Purpose"/>

                          <mx:RadioButtonGroup id="radiogroup1"/>

                          <mx:RadioButton x="147" y="28" label="Routine" groupName="radiogroup1"/>

                          <mx:RadioButtonGroup id="radiogroup2"/>

                          <mx:Label x="88" y="217" text="Date of Onset"/>

                          <mx:TextInput x="195" y="215" width="120"/>

                          <mx:TextArea x="192" y="133" height="70" width="333"/>

                          <mx:Label x="107" y="171" text="Symptoms"/>

                          <mx:Button x="282" y="267" label="Save "/>

                          <mx:Button x="359" y="267" label="Exit"/>

                          <mx:Button x="432" y="267" label="Edit"/>

                          <mx:Label x="88" y="95" text="Purpose of Visit"/>

                          <mx:TextInput x="-1" y="-1" width="768" backgroundColor="#EEEBEB">

                          <mx:text><![CDATA[ Patient, One 123-65-9987 01/01/1947 Date / Time]]></mx:text>

                          </mx:TextInput>

                          <mx:TextArea x="192" y="81" width="315"/>

                          <mx:RadioButton x="148" y="50" label="Sick"/>

                          </mx:TitleWindow>

                          • 10. Re: Call child window
                            xpad1 Level 1

                            Thanks for your help

                            I am still getting following error in main application

                             

                            1046: Type was not found or was not a compile-time constant: CloseEvent. Vitals/src Vitals.mxml line 15 

                             

                             

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

                            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="755.2" height="620">

                            <mx:Script>

                            <![CDATA[

                            //import flash.events.Event;

                            private function openChildWindow():void

                            {

                            var pov:pov = ChildWindowFileName(PopUpManager.createPopUp(this, pov, true));

                            pov.addEventListener(CloseEvent.CLOSE, onCloseChildWindow);

                             

                            }

                             

                             

                            // handler for closing window

                            private function onCloseChildWindow(event:CloseEvent):void {

                            PopUpManager.removePopUp(IFlexDisplayObject(event.target));

                            }

                            ]]>

                             

                            </mx:Script>

                             

                             

                            <mx:FormHeading x="311" y="10" label="VITALS " color="#D12448" fontWeight="bold" textDecoration="underline" fontFamily="Times New Roman" fontSize="20"/>

                            <mx:Panel x="20" y="411" width="723" height="114" layout="absolute" title="Date/Time Vital Value Entered By Purpose Of Visit" fontFamily="Times New Roman" fontSize="12" color="#020007" backgroundColor="#F9F9FB" borderColor="#6B84EE" themeColor="#6467E2">

                            </mx:Panel>

                            <mx:Button x="351" y="533" label="Exit" color="#F4240E" fontFamily="Arial"/>

                            <mx:Text x="71" y="383" text="Latest Vitals for this Patient" fontFamily="Times New Roman" color="#090001" fontSize="14" fontWeight="bold"/>

                            <mx:Panel x="20" y="47" width="723" height="328" layout="absolute" color="#0C0C0C" backgroundColor="#F6F7FB" borderColor="#6484EE" themeColor="#6467E2">

                            <mx:title><![CDATA[Patient, One ]]></mx:title>

                            <mx:Label x="32" y="49" text="Temperature" color="#000207" fontFamily="Arial" fontSize="13"/>

                            <mx:TextInput x="273" y="50" width="87"/>

                            <mx:Label x="32" y="79" text="Pulse" color="#000108" fontFamily="Verdana" fontSize="12"/>

                            <mx:Label x="33" y="167" text="Respiration" color="#010006" fontFamily="Verdana" fontSize="12"/>

                            <mx:Label x="32" y="108" text="Pain" color="#000900" fontSize="12"/>

                            <mx:Label x="32" y="137" text="Blood Pressure" color="#000108" fontSize="12"/>

                            <mx:Label x="33" y="197" text="Height" color="#000003" fontSize="12"/>

                            <mx:TextInput x="273" y="79" width="87"/>

                            <mx:TextInput x="273" y="109" width="87"/>

                            <mx:TextInput x="273" y="137" width="87"/>

                            <mx:TextInput x="273" y="167" width="87"/>

                            <mx:TextInput x="273" y="197" width="87"/>

                            <mx:Label x="34" y="228" text="Weight" color="#000007" fontSize="12"/>

                            <mx:TextInput x="273" y="226" width="87"/>

                            <mx:FormHeading x="32" y="22" label="VITAL" color="#050001" textDecoration="underline"/>

                            <mx:FormHeading x="273" y="22" label="VALUE" color="#060000" textDecoration="underline"/>

                            <mx:Button x="256" y="256" label="Save" color="#F42C11" fontFamily="Arial" fontWeight="bold"/>

                            <mx:Button x="334" y="256" label="Edit" color="#F42C11"/>

                            <mx:Button x="492" y="167" label="Purpose of Visit"

                            click="openChildWindow()"/>

                            <mx:TextInput x="-1" y="-1" width="714" backgroundColor="#EEEBEB">

                            <mx:text><![CDATA[ Patient, One 123-65-9987 01/01/1947 Date / Time]]></mx:text>

                            </mx:TextInput>

                            </mx:Panel>

                            <mx:Button x="242" y="535" label="Save And Exit" fontFamily="Arial" fontSize="9" width="93" color="#F4160B" fontWeight="bold"/>

                            </mx:Application>

                             

                             

                            • 11. Re: Call child window
                              _Natasha_ Level 4

                              Add in Script block

                              import mx.events.CloseEvent;

                              • 12. Re: Call child window
                                xpad1 Level 1

                                Natasha,

                                 

                                It worked, Thank a lot

                                 

                                Padma

                                • 13. Re: Call child window
                                  xpad1 Level 1

                                  Could you please tell me what is event in the following code, from where event is getting the value

                                   

                                   

                                  </mx:Application

                                  • 14. Re: Call child window
                                    _Natasha_ Level 4

                                    Close button in child TitleWindow generates CloseEvent.

                                    Or you mean another event?

                                     

                                    Mark theme as solved if it's so.