加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex_向弹出式窗口传递数据;

发布时间:2020-12-15 05:09:59 所属栏目:百科 来源:网络整理
导读:效果图: =WindowSendMessageWith.mxml自定义组件; ?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.a

效果图:


=>WindowSendMessageWith.mxml自定义组件;

<?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="350" height="230" title="User Manager({_users.length} users)" close="onCloseWind()" creationComplete="initFn()">
?? ?
?? ?<fx:Script>
?? ??? ?<![CDATA[
?? ??? ??? ?import mx.managers.PopUpManager;
?? ??? ??? ?
?? ??? ??? ?/**
?? ??? ??? ? * 关闭窗口;
?? ??? ??? ? */
?? ??? ??? ?protected function onCloseWind():void{
?? ??? ??? ??? ?PopUpManager.removePopUp(this);
?? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ?/**
?? ??? ??? ? * 初始化组件_如果是弹出窗口就居中显示;
?? ??? ??? ? */
?? ??? ??? ?protected function initFn():void{
?? ??? ??? ??? ?if(isPopUp) {
?? ??? ??? ??? ??? ?PopUpManager.centerPopUp(this);
?? ??? ??? ??? ?}
?? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ?[Bindable]
?? ??? ??? ?private var _users:Array;?? ?// 组件属性;
?? ??? ??? ?public function get users():Array{
?? ??? ??? ??? ?return _users;
?? ??? ??? ?}
?? ??? ??? ?public function set users(value:Array):void{
?? ??? ??? ??? ?_users = value;
?? ??? ??? ?}
?? ??? ?]]>
?? ?</fx:Script>
?? ?
?? ?<mx:DataGrid id="usersList" width="100%" height="100%" dataProvider="{_users}"/>
?? ?
</s:TitleWindow>


=>主应用程序

<?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" ?? ??? ??? ??? minWidth="1024" minHeight="768" pageTitle="TheStudioOfCenyebao" ?? ??? ??? ??? applicationComplete="initFn()"> ?? ? ?? ?<fx:Script> ?? ??? ?<![CDATA[ ?? ??? ??? ?import com.learn.Window.WindowSendMessageWith;?? ?// 自定义窗口; ?? ??? ??? ? ?? ??? ??? ?import mx.managers.PopUpManager; ?? ??? ??? ? ?? ??? ??? ?protected var _userWind:WindowSendMessageWith;?? ?// 声明组件变量; ?? ??? ??? ? ?? ??? ??? ?/** ?? ??? ??? ? * 初始化; ?? ??? ??? ? */ ?? ??? ??? ?protected function initFn():void{ ?? ??? ??? ??? ?// 初始化窗体; ?? ??? ??? ??? ?_userWind = new WindowSendMessageWith(); ?? ??? ??? ?} ?? ??? ??? ? ?? ??? ??? ?protected function viewBtn_clickHandler(event:MouseEvent):void ?? ??? ??? ?{ ?? ??? ??? ??? ?PopUpManager.addPopUp(_userWind,this,true);?? ?// 打开窗口; ?? ??? ??? ??? ?// 数据; ?? ??? ??? ??? ?generateData(); ?? ??? ??? ?} ?? ??? ??? ? ?? ??? ??? ?protected function generateData():void{ ?? ??? ??? ??? ?var users:Array = new Array(); ?? ??? ??? ??? ? ?? ??? ??? ??? ?var totalRecords:uint = Math.round(Math.random()*100); ?? ??? ??? ??? ?var name:String; ?? ??? ??? ??? ?for(var i:uint=0; i<totalRecords; i++) { ?? ??? ??? ??? ??? ?name = "User" + i.toString(); ?? ??? ??? ??? ??? ?users.push({name: name,email: name+"@lf.com"}); ?? ??? ??? ??? ?} ?? ??? ??? ??? ?_userWind.users = users; ?? ??? ??? ?} ?? ??? ??? ? ?? ??? ?]]> ?? ?</fx:Script> ?? ?<s:Button id="viewBtn" label="查看用户信息" horizontalCenter="0" verticalCenter="0" click="viewBtn_clickHandler(event)"/> ?? ? </s:Application>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读