The Way To Great

通往伟大的路

用户操作
[即时聊天] [发私信] [加为好友]
AlbertID:zinking3
59410次访问,排名1789(-1)好友15人,关注者22
where there is a will,there is a way to great.
zinking3的文章
原创 191 篇
翻译 6 篇
转载 14 篇
评论 27 篇
Albert的公告
最近评论
yiyi:这个功能我知道

但是,这玩艺怎么去掉?我有个地方控制buttonbar里的内容根据鼠标缩放,缩到一半文字给截了,它就给我弹个tooltip出来- -

buttonbar又没有itemRenderer这样的属性,就算有,也不可能放label,要知道button怎么去掉这个功能也好办啊
奇怪的jane:so, reference is changed to have different value, but if you assume now each listener received different value , its not correct, they will both received latest assigned value . overall inline fun……
sap99:www.sap99.com/,SAP99资料多多

SAP免费资料下载
http://www.sap99.com

有很多的学习资料,推荐一下,
ocean:Loading Collada Files into Papervision3D

Testing Kinematics with Papervision3D Collada

DCC Tutorials
怎么没连接,请楼主修复下,谢谢!!!
空军一号:太好了!
爱死你了,哈哈
文章分类
收藏
相册
RIA的朋友们
不会飞的鱼
更新很快,关注业内的RIA朋友Y-Boy(RSS)
存档
订阅我的博客
XML聚合  FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
订阅到BlogLines
订阅到Yahoo
订阅到GouGou
订阅到飞鸽
订阅到Rojo
订阅到newsgator
订阅到netvibes

原创 如何向事件监听器传送额外的参数收藏

新一篇: 【ZZ】GPU上并行处理大规模粒子系统 | 旧一篇: 立方体的着色,阴影效果,过度效果

如何向事件监听器传送额外的参数


问题摘要

在FLEX文档中所述的是,如果你要向监听器传送参数,那么你最好使用MXML标签,但是在这里要展示给你的是如何使用AS脚本完成。

解决摘要

使用内联函数

解释

solution is very simple, basically for  following scenario :
arbitrary button called ABCButton,function ABCButtonListener needs to listen to click event and also receive extra parameter 

"myPrivateSpecialObject"
object.

 you do following :

private function ABCButtonListener(e:MouseEvent,specialObj:Object): void {
Alert.show(specialObj.name);
}


private function methodWhereyouDostuffAndRegisterListener(): void {
var myPrivateSpecialObject:Object = {name:"Special String Ingredients for Orange"};

      ABCButton.addEventListener(MouseEvent.CLICK,function (e:MouseEvent) : void {
ABCButtonListener(e,myPrivateSpecialObject);
});
}
P.S -----------------

you can use same structure to register listener for more than one button,for example :


private function methodWhereyouDostuffAndRegisterListener(): void {
var myPrivateSpecialObject:Object = {name:"Special String Ingredients for Orange"};

      ABCButton.addEventListener(MouseEvent.CLICK,function (e:MouseEvent) : void {
ABCButtonListener(e,myPrivateSpecialObject);
});



myPrivateSpecialObject = {name:"Special Ingredients for Apple"};

OtherButtonButton.addEventListener(MouseEvent.CLICK,function (e:MouseEvent) : void {
ABCButtonListener(e,myPrivateSpecialObject);
});

}


            above  code registers same listener for two buttons but before registering second listener , we try to modify
myPrivateSpecialObject 
  so, reference is changed to have different value, but if you assume now each listener received different value , its not correct, they will both received latest assigned value .  overall inline function is good technique to pass   any number of parameters to a listener as long as listener is ready for those parameters.        
           
      

Related files for download


bin-release1.zip

main.swf

发表于 @ 2008年05月31日 15:01:24|评论(loading...)|编辑

新一篇: 【ZZ】GPU上并行处理大规模粒子系统 | 旧一篇: 立方体的着色,阴影效果,过度效果

评论

#奇怪的jane 发表于2008-09-24 10:01:18  IP: 117.32.153.*
so, reference is changed to have different value, but if you assume now each listener received different value , its not correct, they will both received latest assigned value . overall inline function is good technique to pass any number of parameters to a listener as long as listener is ready for those parameters.

注意后面一句,传递过去的是个对象的引用,因此在触发时,所有的触发对象引用到的参数都讲是该对象当时的值,也就是不能传递不同的参数过去。。。
发表评论  


登录
Csdn Blog version 3.1a
Copyright © Albert