zoukankan      html  css  js  c++  java
  • 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>

  • 相关阅读:
    Json-lib使用 转载
    利用PinYin4j 实现List中的对象按数字,字母, 汉字排序
    web 模板 类似京东左侧的导航栏
    常见挂马方式
    JS挂马攻防
    代码中的202.102.100.100
    利用Jquery获取、设置iframe中元素
    [PHP]基本排序(冒泡排序、快速排序、选择排序、插入排序、二分法排序)
    js验证输入的金钱格式
    js获取当前对象的颜色判断改变颜色
  • 原文地址:https://www.cnblogs.com/xinzhuangzi/p/4100570.html
Copyright © 2011-2022 走看看