• flex 事件机制实解


    主页面:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init();" layout="absolute">
    <mx:Script>
       <![CDATA[
        import myComponents.CustomEvent;
       ]]>
    </mx:Script>

    <mx:Script>
       <![CDATA[
        import mx.managers.PopUpManager;
        import myComponents.titleWin;
        import mx.collections.ArrayCollection;
        import mx.controls.Alert;
        private function init():void{
         addEventListener("test",handlerTEST,true);
        
         var dataProvider:ArrayCollection = new ArrayCollection([
         {name:"lixx1",task:"lixx1"},{name:"lixx2",task:"lixx2"},{name:"lixx3",task:"lixx3"}]);
        
         this.myDatagrid.dataProvider = dataProvider;
        }
       
        private function handlerTEST(event:CustomEvent):void{
         //Alert.show(""+(event as CustomEvent).getOBJ.name);
         var win:titleWin = titleWin(PopUpManager.createPopUp(this,titleWin,true)) ;
         win.userName.text = "lixx";
         win.password.text = "lixx";
         PopUpManager.centerPopUp(win);
        }
       ]]>
    </mx:Script>
    <mx:DataGrid id="myDatagrid">
       <mx:columns>
        <mx:DataGridColumn headerText="姓名" dataField="name">
        </mx:DataGridColumn>
        <mx:DataGridColumn headerText="任务" dataField="task">
        </mx:DataGridColumn>
        <mx:DataGridColumn headerText="操作">
         <mx:itemRenderer>
          <mx:Component>
           <mx:Button label="TEST" click="cli();">
            <mx:Script>
            <![CDATA[
             import myComponents.CustomEvent;
             private function cli():void{
              dispatchEvent(new CustomEvent("test",data));
             }
            ]]>
            </mx:Script>
           </mx:Button>
          </mx:Component>
         </mx:itemRenderer>
        </mx:DataGridColumn>
       </mx:columns>
    </mx:DataGrid>
    </mx:Application>

    窗体页面:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal"
    creationComplete="init();" width="400" height="300" showCloseButton="true"
    close="remove(event);">
    <mx:Script>
       <![CDATA[
        import mx.controls.Alert;
        import mx.events.CloseEvent;
        private function init():void{
         this.submit.addEventListener(MouseEvent.CLICK,submit1);
         this.cancel.addEventListener(MouseEvent.CLICK,cancel1);
        }
       
        private function remove(event:CloseEvent):void{
        
        }
        private function submit1(event:MouseEvent):void{
         Alert.show("success login");
        }
        private function cancel1(event:MouseEvent):void{
         Alert.show("success logout");
        }
       ]]>
    </mx:Script>
    <mx:Form id="myForm">
       <mx:FormHeading label="用户登录">
       
       </mx:FormHeading>
       <mx:FormItem label="用户名: ">
        <mx:TextInput id="userName" text="" />
       </mx:FormItem>
       <mx:FormItem label="密码: ">
        <mx:TextInput id="password" text="" />
       </mx:FormItem>
       <mx:FormItem direction="horizontal">
        <mx:Button label="submit" id="submit"/>
        <mx:Button label="cancel" id="cancel"/>
       </mx:FormItem>
    </mx:Form>
    </mx:TitleWindow>

  • 相关阅读:
    2019 年年终总结
    Java/C# 中为何需要 Getter/Setter?
    使用 supervisord 设置应用开机启动
    Linux 性能监控与故障排查:主要性能指标说明及监控方法
    「Bug」Jenkins Slave 卡顿与僵尸进程
    HTTP/HTTPS 的监听方法,以及浏览器与服务器的协议协商机制
    查询主机公网ip
    Linux Server Swap 分区设置
    Kubernetes 常见错误
    Kubernetes 学习笔记(五):数据卷
  • 原文地址:https://www.cnblogs.com/xinzhuangzi/p/4100570.html
Copyright © 2020-2023  润新知