0
嗨 我有2個MXML文件中....問題與LinkButton的鼠標事件
CustComp.mxml
<mx:LinkButton id="linkbutton" label="ClickMe" click="onLinkClicked()" mouseOver="onMouseOver()" mouseOut="onMouseOut()" />
private function onLinkClicked():void{
dispatchEvent(new CustomEvent("onClick");}
private function onMouseOver(event:CustomEvent):void{
dispatchEvent(new CustomEvent("onMouseOver");}
private function onMouseOut(event:CustomEvent):void{
dispatchEvent(new CustomEvent("onMouseOut");}
Main.mxml
var customComp:CustComp = new CustComp();
customComp.addEventListener(CustomEvent.MOUSE_CLICK1,onLinkClicked111);
customComp.addEventListener(CustomEvent.MOUSE_OVER1,onMouseOver111);
customComp.addEventListener(CustomEvent.MOUSE_OUT1,onMouseOut111);
private function onLinkClicked111(event:CustomEvent):void{
trace("click event");}
private function onMouseOver111(event:CustomEvent):void{
trace("mouse over event");}
private function onMouseOut111(event:CustomEvent):void{
trace("mouse out event");}
當我想提出一個鼠標懸停或鼠標懸停在組件中的鏈接按鈕上,事件將被分派到main.mxml,並且各個函數都會被完美調用。但是,當我單擊該按鈕時,onLinkClicked111()函數n被調用一次,並且onMouseOut111(),onMouseOver111()被重複調用,直到我使光標離開鏈接按鈕。 請幫我一下,我應該怎麼做以確保當我點擊時,只有onLinkclicked111()函數應該被調用,而不是mouseOver111()或mouseOut111()