可以从另一个动画片段中控制动画片段组件吗?

时间:2011-12-24 19:05:22

标签: flash actionscript-3 flash-cs3

我想从movieclip“B”中控制movieclip“A”组件。

movieclip A:

function click1(event:MouseEvent):void
{ 
  // I want to change text of button which is inside movieclip "B" in here.
}

btn1.addEventListener(MouseEvent.CLICK , click1);

movieclip B:

function click2(event:MouseEvent):void
{ 
  //and here I want to change text of button which is inside movieclip "A".
}

btn2.addEventListener(MouseEvent.CLICK , click2);

我该怎么做?

抱歉我的英语。

1 个答案:

答案 0 :(得分:3)

假设两个动画片段(mcamcb)已添加到stage - stage是两者的父级 - 这很简单为:

function click1(event:MouseEvent):void
{ 
    // I want to change text of button which is inside movieclip "B" in here.
    stage.mca.someButtonObject.label = "some new button text";
}

function click2(event:MouseEvent):void
{ 
    //and here I want to change text of button which is inside movieclip "A".
    stage.mcb.someTextboxObject.text = "some new text";
}

稍微测试一下这段代码,如果这不起作用,请告诉我(如果失败,请发贴你的代码)。