我有一個movieclip裏面有兩個按鈕。mc裏面的按鈕影響代碼
問題是,當鼠標懸停在這兩個按鈕上時,管理影片剪輯的代碼停止工作,就好像鼠標不在MC上一樣(按鈕是MC的子項,不應該用於操作?)。
請您分享一些建議嗎? 感謝
/*mc follows mouse. I can't click btns because when mouse rollover btns the mc moves*/
function showImgOptions (e:Event):void{
if (mc.hitTestPoint(mouseX,mouseY,false)){
mc.y = mc.y;
mc.x = mc.x;
}else{
var delayX:int = mc.x - mouseX;
var delayY:int = mc.y - mouseY;
mc.x -= delayX/6;
mc.y -= delayY/6;
}
}
mc.btn1.addEventListener (MouseEvent.CLICK, closeClick);
mc.btn2.addEventListener (MouseEvent.CLICK, zoomClick);
function closeClick (e:MouseEvent):void{}
function zoomClick (e:MouseEvent):void{}
stage.addEventListener (Event.ENTER_FRAME, showImgOptions);
addChild (mc);
改變了代碼:
var mc:menuMC = new menuMC();
addChild(mc);
var p:Point = mc.localToGlobal(new Point(mc.mouseX,mc.mouseY));
/*mc follows mouse. I can't click btns because when mouse rollover btns the mc moves*/
function showImgOptions (e:Event):void
{
if (! mc.hitTestPoint(p.x,p.y,false))
{
mc.y = mc.y;
mc.x = mc.x;
}else{
//move mc towards mc.parent's mouseX and mouseY
var delayX:int = mc.x - mouseX;
var delayY:int = mc.y - mouseY;
mc.x -= delayX/6;
mc.y-=delayY/6;
}
}
mc.btn1.addEventListener (MouseEvent.CLICK, closeClick);
mc.btn2.addEventListener (MouseEvent.CLICK, zoomClick);
function closeClick (e:MouseEvent):void
{
}
function zoomClick (e:MouseEvent):void
{
}
stage.addEventListener (Event.ENTER_FRAME, showImgOptions);
現在我得到這個錯誤:
TypeError: Error #1010: A term is undefined and has no properties.
Here,你可以下載一個FLA。測試並嘗試按一下按鈕1和2,MC裏面的鼠標
你可以發佈代碼嗎? – Allan 2009-10-29 01:28:53
當鼠標不在mc上時,你是否試圖讓mc跟隨鼠標,並在鼠標懸停在mc上時保持其靜止? – Amarghosh 2009-10-29 14:00:18
是的,這就是我想要做的 – cayohueso 2009-10-29 17:01:02