zoukankan      html  css  js  c++  java
  • FLEX 绑定事件中多参数传递

    flex 在事件中添加自己的参数的方法:

    var parentItem:XML;

    var service1:HTTPService=new HTTPService();

    ..................此处省略

    service1.addEventListener(ResultEvent.RESULT, function (e:ResultEvent):void{onGetChildTables(e,parentItem)}); //这里item就是自己定义的参数,

    ....................此处省略

    这样在ResultEvent函数中就可以使用传入的参数了。

    private function onGetChildTables(evt:ResultEvent,parentItem:XML):void{  //添加Tree控件的子节点
        var xml : XML = evt.result as XML;
        var itemList:XMLListCollection=new XMLListCollection(xml.Item);
        if(itemList.length>0){
            delete parentItem.children()[0]; //删除占位子节点
            for each(var item : XML in itemList){
                parentItem.appendChild(item); //添加实际的子节点
            }
        }
    }

    =============================================

    监听在开发中使用的很多,但是addEventListener函数除了加事件类型和调用函数外,能不能加额外的参数呢?

    其实是可以的,只要把所加的函数改为新定义的函数,在定义的函数中加入参数即可,示例:

    private function handle(e:MouseEvent,str:String): void

    {
           Alert.show(str);
    }
    private function methodWhereyouDostuffAndRegisterListener(): void

    {
        var helloStr:String = "hello world!";
        ABCButton.addEventListener(MouseEvent.CLICK,function (e:MouseEvent):void {handle(e,helloStr);});
    }

  • 相关阅读:
    CocoaPods使用和在新工程中创建xcworkspace
    CocoaPods的安装使用和常见问题
    iMac上安装cocoapods步骤
    error:could not read data from info
    :after伪类+content内容生成
    无JavaScript实现选项卡轮转切换效果
    margin负值的相关应用
    absolute元素 text-align属性
    绝对定位元素的水平垂直居中
    flex 布局
  • 原文地址:https://www.cnblogs.com/zcy_soft/p/1976790.html
Copyright © 2011-2022 走看看