2010-12-17 81 views
1

我不知道我的腳本正在發生什麼,但MOUSE_DOWN和CLICK事件不起作用。這是actionscript 3.0。 MOUSE_OVER工作正常。MOUSE_DOWN和CLICK不起作用

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); 
} 

回答

3

你需要把對beginFill線的drawRect

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

上面你基本上是製作方空缺,否則。

+0

非常感謝...很容易..對不起,我不能接受答案,因爲我只有14個聲望 – NanoHead 2010-12-17 17:59:33

+0

你能給我+1嗎?也許那麼 – 2010-12-17 18:00:49

+0

只是,謝謝你 – NanoHead 2010-12-17 19:11:15