好吧,只要您的鼠標實際上在物品上或它的一個孩子身上,那麼mouseOver和RollOver以及它們各自的輸出效果都很好。我的問題是,我可能有另一個UI組件「之間」我的鼠標和我想要處理鼠標/滾動(可能是一個按鈕是在畫布的頂部,但不是畫布的孩子)的項目。鼠標仍然在組件上,還有其他的東西在同一時間結束。我需要一個真正的mouseOver
任何提示或幫助如何處理?如果我不夠清楚,請告訴我。
下面是一個簡單的代碼示例,詳細說明我的問題複製/粘貼到您的Flex/Flash Builder中,你會明白我的意思: 編輯,我只是做這個比較複雜和真實的我的實際問題,拖慢慢的,如果進一步移動鼠標比它有點打破單個幀按鈕,但也只是在這個簡化版本
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="500" height="268"
creationComplete="ccInit()">
<mx:Script>
<![CDATA[
private var btnStartX:Number = 10;
private var btnStartY:Number = 218;
private var msStartX:Number = 0;
private var msStartY:Number = 0;
private function ccInit():void{
myCanv.addEventListener(MouseEvent.ROLL_OVER,handleRollOver);
mybutton.addEventListener(MouseEvent.MOUSE_DOWN,startDragOp);
}
private function handleRollOver(evt:MouseEvent):void{
myCanv.setStyle("backgroundAlpha",1);
myCanv.addEventListener(MouseEvent.ROLL_OUT,handleRollOut);
mybutton.mouseEnabled = false;
mybutton.focusEnabled = false;
mybutton.mouseFocusEnabled = false;
mybutton.mouseChildren = false;
}
private function handleRollOut(evt:MouseEvent):void{
myCanv.setStyle("backgroundAlpha",0);
myCanv.removeEventListener(MouseEvent.ROLL_OUT,handleRollOut);
mybutton.mouseEnabled = true;
mybutton.focusEnabled = true;
mybutton.mouseFocusEnabled = true;
mybutton.mouseChildren = true;
}
private function startDragOp(evt:MouseEvent):void{
btnStartX = mybutton.x;
btnStartY = mybutton.y;
msStartX = stage.mouseX;
msStartY = stage.mouseY;
mybutton.addEventListener(MouseEvent.MOUSE_MOVE,moveWithMouse);
mybutton.addEventListener(MouseEvent.MOUSE_UP,endDragOp);
}
private function moveWithMouse(evt:MouseEvent):void{
mybutton.x = btnStartX + stage.mouseX - msStartX;
mybutton.y = btnStartY + stage.mouseY - msStartY;
}
private function endDragOp(evt:MouseEvent):void{
mybutton.x = 10;
mybutton.y = 218;
mybutton.removeEventListener(MouseEvent.MOUSE_MOVE,moveWithMouse);
mybutton.removeEventListener(MouseEvent.MOUSE_UP,endDragOp);
}
]]>
</mx:Script>
<mx:Canvas id="myCanv" x="10" y="10" width="480" height="200" borderStyle="solid" borderColor="#000000" backgroundColor="#FFFFFF" backgroundAlpha="0">
</mx:Canvas>
<mx:Button id="mybutton" x="10" y="218" label="Drag me over above canvas" width="326" height="36"/>
</mx:Application>
我前面的例子太簡單了,這新的更準確的我遇到的問題。 – invertedSpear 2010-05-21 15:58:25