Flex Parent-Child windows call each other

Source: Internet
Author: User

Flex Parent-Child windows call each other

(1) Parent window

Parentwindow.mxml:

<?xml version="1.0"encoding="Utf-8"?> <s:application xmlns:fx="http://ns.adobe.com/mxml/2009"xmlns:s="Library://ns.adobe.com/flex/spark"xmlns:mx="LIBRARY://NS.ADOBE.COM/FLEX/MX"width="100%"height="100%"> <s:layout> <s:basiclayout/> </S:layout> <fx:Declarations> <!--put non-visual elements (such as services, value objects) here--</Fx:declarations> <fx:Script> <![cdata[Importmx.collections.ArrayCollection;ImportMx.controls.Alert;ImportMx.managers.PopUpManager; [Bindable] //Tabular data Source bindingsPrivate varGrid:arraycollection =Newarraycollection ([{ Number:"2014010101", Name:"Zhang Scattered", Sex:"Male", Age:"All"}, { Number:"2014010102", Name:"Li si", Sex:"female", Age:"a"}, { Number:"2014010101", Name:"Prince", Sex:"Male", Age:"very"}, { Number:"2014010101", Name:"Zhao Liu", Sex:"female", Age:"a"}, { Number:"2014010101", Name:"tour of China", Sex:"Male", Age:"a"}, { Number:"2014010101", Name:"Soath", Sex:"female", Age:" "}, { Number:"2014010101", Name:"Zhou Li", Sex:"Male", Age:"very"}, { Number:"2014010101", Name:"Hua Jie", Sex:"female", Age:"a"}, { Number:"2014010101", Name:"Liuliang", Sex:"Male", Age:"a"}, { Number:"2014010101", Name:"Shen She", Sex:"female", Age:"very"} ]); /*Modifying event functions*/protectedfunctionUpdatehandler (event:mouseevent):void { //new Child Form ObjectvarChildwindow:childwindow =NewChildWindow ();//Add a subform to PopupmanagerPopupmanager.addpopup (ChildWindow, This,true); //passing parameters to the subformChildwindow.age ="All"; //child window Call Parent window functionChildwindow.callback = This. myFunction;//Child Form Center PopupPopupmanager.centerpopup (ChildWindow);} /*Refresh function*/  Public functionMyFunction (you:string):void{alert.show ( you+"Hello"); } ]]> </Fx:script> <mx:vbox width="100%"height="100%"Paddingbottom="Ten"paddingleft="Ten"paddingright="Ten"paddingtop="Ten"> <mx:datagrid id="DataGrid"Dataprovider=' {grid} 'Rowcount="{grid.length + 1}"Width="100%"verticalalign="Middle"textalign="Center"> <mx:columns> <mx:datagridcolumn headertext="School Number"Datafield="Number"/> <mx:datagridcolumn headertext="Name"Datafield="Name"/> <mx:datagridcolumn headertext="Gender"Datafield="Sex"/> <mx:datagridcolumn headertext="Age"Datafield="Age"/> </Mx:columns> </Mx:datagrid> <mx:hbox width="100%"horizontalalign="Center"verticalalign="Middle"> <s:button label="Modify"click="Updatehandler (Event)"/> </Mx:hbox> </Mx:vbox> </S:application>

(2) Sub-window

<?xml version="1.0"encoding="Utf-8"?> <s: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"Width="+"height=" the"Close="Closehandler (event)"title="Modify Window"> <s:layout> <s:basiclayout/> </S:layout> <fx:Script> <![cdata[Importmx.events.CloseEvent;ImportMx.managers.PopUpManager;//callback function Public varcallback:function; Public varAge:string =""; /*Close Event Function*/protectedfunctionClosehandler (event:closeevent):void{popupmanager.removepopup ( This); } /*Modify the button event function*/protectedfunctionUpdatehandler (event:mouseevent):void{Stuage.text=Age ;} /*Cancel button Event function*/protectedfunctionCancelhandler (event:mouseevent):void {  Number. Text =""; Stuname.text=""; Popupmanager.removepopup ( This); if(ispopup) {callback.call (parent);}} ]]> </Fx:script> <fx:Declarations> <!--put non-visual elements (such as services, value objects) here--</Fx:declarations> <mx:vbox width="100%"height="100%"> <mx:Form> <mx:formitem label="School Number:"> <s:textinput id="Number"Width=" the"maxchars="Ten"/> </Mx:formitem> <mx:formitem label="Name:"> <s:textinput id="Stuname"Width=" the"maxchars="Ten"/> </Mx:formitem> <mx:formitem label="Gender:"> <mx:hbox width="100%"> <mx:radiobuttongroup id="Sex"/> <s:radiobutton groupname="Sex"Label="Male"Selected="true"/> <s:radiobutton groupname="Sex"Label="female"/> </Mx:hbox> </Mx:formitem> <mx:formitem label="Age:"> <s:textinput id="Stuage"Width=" the"maxchars="2"/> </mx:formitem> <mx:FormItem> <mx:hbox width="100%"> <s:button label="Modify"click="Updatehandler (Event)"/> <s:label width="a"/> <s:button label="Cancel"click="Cancelhandler (Event)"/> </Mx:hbox> </Mx:formitem> </Mx:form> </Mx:vbox> </S:titlewindow>

Flex Parent-Child windows call each other

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.