惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy International News Feed
Martin Fowler
Martin Fowler
D
Docker
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
U
Unit 42
T
Tailwind CSS Blog
J
Java Code Geeks
G
Google Developers Blog
MongoDB | Blog
MongoDB | Blog
阮一峰的网络日志
阮一峰的网络日志
WordPress大学
WordPress大学
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
美团技术团队
F
Fortinet All Blogs
N
News and Events Feed by Topic
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
The GitHub Blog
The GitHub Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Recorded Future
Recorded Future
N
Netflix TechBlog - Medium
Google DeepMind News
Google DeepMind News
Hacker News: Ask HN
Hacker News: Ask HN
L
LINUX DO - 最新话题
Microsoft Security Blog
Microsoft Security Blog
N
News and Events Feed by Topic
I
Intezer
TaoSecurity Blog
TaoSecurity Blog
NISL@THU
NISL@THU
小众软件
小众软件
博客园 - 聂微东
博客园 - Franky
有赞技术团队
有赞技术团队
P
Palo Alto Networks Blog
爱范儿
爱范儿
H
Hacker News: Front Page
C
Cyber Attacks, Cyber Crime and Cyber Security
C
Cisco Blogs
P
Proofpoint News Feed
I
InfoQ
Google DeepMind News
Google DeepMind News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Vercel News
Vercel News
H
Heimdal Security Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
量子位

博客园 - 帅死活该

Flex各类型坐标转换(全局、本地、内容坐标间转换) Oracle Spatial中的空间索引 [转] ORACLE纯SQL实现多行合并一行[转] Oracle提供的序号函数 自定义组件开发 第二节 MXML组件开发 Flex项目调试及日志记录 Flex或Flash的跨域访问的解决方案 - 帅死活该 - 博客园 ArcEngine数据删除几种方法和性能比较[转] - 帅死活该 - 博客园 组件服务-计算机-我的电脑右键无属性,组件服务打不开 FLEX中使用BitmapFill的source属性指定SVG类文件 - 帅死活该 - 博客园 [转]ArcSDE数据被锁定后的解锁方法 ArcGIS server如何将自己的小地图叠加到Google maps或者Virtual Earth上[转] 一个ArcGIS网络分析的最短路径例子||A Network Analyst Shortest Route of ArcGIS[转] ArcGIS的网络分析[转] Flex动画效果与变换(三)[转] Flex的动画效果与变换!(二)[转] Flex动画效果与变换(一)[转] Microsoft 解决方案框架 — MSF 项目管理准则 v. 1.1[转] 如何在Silverlight中与HTML DOM交互
FLEX动态创建事件
帅死活该 · 2011-04-19 · via 博客园 - 帅死活该

在flex里通过addEventListener函数给控件动态加载click事件侦听函数时,除了事件本身传递的Event类型参数外,还需要传递更多的参数,代码如下:

package
{
    public class EventArgExtend
    {
        public function EventArgExtend()
        {
        }
       
        public static function create(f:Function,... arg):Function
        {
               var F:Boolean=false;
               var _f:Function=function(e:*,..._arg)
               {
                   _arg=arg
                   if(!F)
                   {
                       F=true
                       _arg.unshift(e)
                   }
                   f.apply(null,_arg)
               };
               return _f;
          }
          public static function toString():String
          {
               return "Class JEventDelegate";
          }
    }
}

使用的方式:
txtShow.addEventListener(MouseEvent.CLICK,EventArgExtend.create(clickHandler,1,"str"));

            private function clickHandler(e:Event,...arg):void
            {
                Alert.show(arg[0].toString());
                Alert.show(arg[1].toString());
            }


还有另外一个方法,没有封装效果,不过代码更加容易理解:

var sayHello:String = "123456";
btn1.addEventListener(MouseEvent.CLICK,function (e:MouseEvent){clickHandlerWithArg(e,sayHello)});
function clickHandlerWithArg(e:MouseEvent,arg:String):void
{
var out:String= e.target + "发出事件(有参数) :" + arg;
trace(out);
}