MOUSE_DOWN和CLICK不起作用

时间:2010-12-17 17:41:25

标签: actionscript-3

我不知道我的脚本发生了什么,但MOUSE_DOWN AND CLICK事件不起作用。这是actionscript 3.0。 MOUSE_OVER工作正常。

var myCell:MovieClip = new MovieClip(); 
myCell.graphics.clear();
myCell.graphics.lineStyle(1, 0xfff000);//add yellow border
myCell.graphics.drawRect(0, 0, 100, 100); 
myCell.graphics.beginFill(0xffffff);//Fill with white
myCell.graphics.endFill(); 
myCell.x=300;
myCell.y=300;
myCell.name="testxx";
addChild(myCell);
myCell.addEventListener(MouseEvent.MOUSE_OVER, fnMouseOver);
myCell.addEventListener(MouseEvent.MOUSE_DOWN, fnMouseDown);
myCell.addEventListener(MouseEvent.CLICK, fnMouseClick);


function fnMouseOver(evt:MouseEvent):void{
     trace("fnMouseOver"+evt.target.name);
}

function fnMouseDown(evt:MouseEvent):void{
     trace("fnMouseDown"+evt.target.name);
}

function fnMouseClick(evt:MouseEvent):void{
     trace("fnMouseClick"+evt.target.name);
}

1 个答案:

答案 0 :(得分:3)

您需要将beginFill行放在drawRect

之上
myCell.graphics.beginFill(0xffffff);//Fill with white
myCell.graphics.drawRect(0, 0, 100, 100); 
myCell.graphics.endFill();

否则你实际上是在制作一个未填充的广场。

相关问题