打印

[AS3] 如何removeEventListener掉这个function

package {
       public class JDelegate {
              public static  function create(f:Function,...arg):Function {
                     var _arg:Array=arg
                     var _f:Function=function () {
                     f.apply(null, _arg);
                     };
                     return _f;
              }
       }
}

for(var i:int = 0; i<10; i++)
         {
       var loadmv:emptymv2 = new emptymv2();
             loadmv.addEventListener(MouseEvent.CLICK, JDelegate.create(testload,i)); //想removeEventListener..
                     loadmv.buttonMode = true;
             addChild(loadmv);
          }

function testload(testload:*):void {
        trace(arg);
}

loadmv.removeEventListener(MouseEvent.CLICK, JDelegate.create(testload,i));  
这样不能remove,不知道该怎么写?

[ 本帖最后由 seconed6 于 2007-9-19 16:23 编辑 ]
申明个数组

for(.....){
functions[i]=JDelegate.create(testload,i)
loadmv.addEventListener(MouseEvent.CLICK,functions[i]);
........
}
for.....
loadmv.removeEventListener(MouseEvent.CLICK,functions[i]);
...........
O啦!多谢!

TOP