我有一个要删除的函数EventListener
,但它给了我以下错误:
Access of undefined property event
这是有问题的代码:
dr_line.addEventListener(MouseEvent.CLICK,drawln);
var test:Boolean;
function drawln(e:MouseEvent):void{
event.currentTarget.removeEventListener(MouseEvent.CLICK, drawln);
stage.addEventListener(MouseEvent.CLICK,click1);
}
var sx,sy,fx,fy,j:int;
function click1(e:MouseEvent):void{
sx=mouseX;
sy=mouseY;
stage.addEventListener(MouseEvent.CLICK,click2);
}
function click2(e:MouseEvent):void{
var i:int;
i=1;
trace(i);
fx=mouseX;
fy=mouseY;
var line:Shape = new Shape();
line.graphics.beginFill(0x00FF00);
line.graphics.moveTo(sx,sy);
line.graphics.lineTo(fx,fy);
this.addChild(line);
}
click1
我尝试对and中的事件侦听器进行相同的删除click2
,但它仍然不起作用。
我究竟做错了什么?