开发者

MOUSE_DOWN and CLICK doesn't work

I have no ideas what is going on with my scripts but the MOUSE_DOWN AND CLICK event doesn't work. This is actionscript 3.0. The MOUSE_OVER IS working fine.

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(Mo开发者_JAVA百科useEvent.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);
}


You need to put the beginFill line above the drawRect

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

You are essentially making a unfilled square otherwise.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜