将事件侦听器添加到影片剪辑内的movieclip

时间:2012-04-06 22:43:49

标签: actionscript-3 movieclip addeventlistener

我这里有4个位于主舞台上的动画片段,以及其中一个影片剪辑中的5个影片剪辑

btn_mc5btn_mc9content_mc内我添加了事件监听器,但它们没有做任何事情。此外,他们正在从“content_mc.btn_mc5.addEventListener(MouseEvent.MOUSE_DOWN, btn5up);”行开始生成错误消息:

  

TypeError:错误#1010:术语未定义且没有属性。在   Untitled_fla :: MainTimeline /帧2()

import flash.events.MouseEvent;

stop();

btn_mc1.gotoAndStop(2);
btn_mc2.stop();
btn_mc3.stop();
btn_mc4.stop();

content_mc.stop();

btn_mc1.addEventListener(MouseEvent.MOUSE_DOWN, btn1up);
btn_mc2.addEventListener(MouseEvent.MOUSE_DOWN, btn2up);
btn_mc3.addEventListener(MouseEvent.MOUSE_DOWN, btn3up);
btn_mc4.addEventListener(MouseEvent.MOUSE_DOWN, btn4up);

content_mc.btn_mc5.addEventListener(MouseEvent.MOUSE_DOWN, btn5up);
content_mc.btn_mc6.addEventListener(MouseEvent.MOUSE_DOWN, btn6up);
content_mc.btn_mc7.addEventListener(MouseEvent.MOUSE_DOWN, btn7up);
content_mc.btn_mc8.addEventListener(MouseEvent.MOUSE_DOWN, btn8up);
content_mc.btn_mc9.addEventListener(MouseEvent.MOUSE_DOWN, btn9up);

function btn1up(event:MouseEvent):void{
    content_mc.gotoAndStop(1);
    reset();
    btn_mc1.gotoAndStop(2);
}
function btn2up(event:MouseEvent):void{
    content_mc.gotoAndStop(2);
    reset();
    btn_mc2.gotoAndStop(2);
}
function btn3up(event:MouseEvent):void{
    content_mc.gotoAndStop(3);
    reset();
    btn_mc3.gotoAndStop(2);
}
function btn4up(event:MouseEvent):void{
    content_mc.gotoAndStop(4);
    reset();
    btn_mc4.gotoAndStop(4);
}
function btn5up(event:MouseEvent):void{
    content_mc.gotoAndStop(1);
    content_mc.btn_mc5.gotoAndStop(1);
}
function btn6up(event:MouseEvent):void{
    content_mc.gotoAndStop(6);

}
function btn7up(event:MouseEvent):void{
    content_mc.gotoAndStop(7);
}
function btn8up(event:MouseEvent):void{
    content_mc.gotoAndStop(8);
}
function btn9up(event:MouseEvent):void{
    content_mc.gotoAndStop(9);
}

function reset():void{
    for(var i = 1; i<= 4; i++){
        var btn_name = getChildByName("btn_mc"+i);
        btn_name.gotoAndStop(1);
        }
}

0 个答案:

没有答案