2012-04-18 109 views
0

幾乎所有Flex組件都具有mouseOver/mouseOut或rollOver/rollOut事件。要求這些事件不是鼠標光標,而是另一個元素,比如Image或Bitmap。使用hitTest代替mouseOver/mouseOut

例如,上面有一個Colomn圖表和圖像動畫,當圖像在列上時,我需要獲取數據(colomn值或索引)。如果它是一個組件,那麼我會使用hitTest。但如果是圖表怎麼辦?

+0

在列的圖像?是吧?您應該查看events.http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/charts/ColumnChart.html#eventSummary – 2012-04-18 17:50:00

+0

我知道所需的事件不是。我需要圖像對圖表組件以及鼠標的反應。 – Astraport 2012-04-18 19:41:24

+0

對不起,我只是不明白你對圖像說什麼 – 2012-04-18 19:58:50

回答

0

難道你不能告訴圖像/位圖不是mouseEnabled?

+0

你是什麼意思mouseEnabled?圖像獨立於鼠標的移動而移動。 – Astraport 2012-04-19 10:08:24

+0

好的,但你可以說'imageSprite.mouseEnabled = false'來防止圖像精靈對鼠標敏感。 – Tino 2012-05-13 20:55:38

0

我不能正確理解你的問題沉綿我嘗試這個...

如果您在圖表上添加mouselisteners,每當事件是派遣檢查..

position.x = event.currentTarget.mouseX; 
position.y = event.currentTarget.mouseY; 

那麼你就可以嘗試使用hitTest。

if(obj.hitTestPoint(position.x,position.y)){ 

} 

,這可能是工作....