How do you bind a variable to a function in as3

后端 未结 5 1472
孤独总比滥情好
孤独总比滥情好 2020-12-21 16:08

I have this code:

for each(var tool in tools){
tool.addEventListener(MouseEvent.MOUSE_DOWN, function(){
    trace(tool); //Always the last tool  
 });
}
         


        
5条回答
  •  天涯浪人
    2020-12-21 16:53

    use as3 signals

    http://www.peterelst.com/blog/2010/01/22/as3-signals-the-best-thing-since-sliced-bread/

    It can cater your problem nicely. Once I have tried signal I can't go back. It's much better than the event system in as3

提交回复
热议问题