如何禁用嵌套Movie Clip中的按钮?

时间:2014-05-05 17:44:09

标签: actionscript-3 flash button movieclip

我有一个Movie Clip,让我们把它叫做A.然后在A里面,我有另一个Movie Clip,让我们称之为B,然后在B里面,我有另一个Movie Clip,我们称之为C,而CI里面有几个需要暂时禁用的按钮。可能吗?我试过了

A.B.C.enabled=false;

A.B.C.mouseEnabled=false;

那不行。但是我找到了一种方法。

A.B.C.buttonInsideC.mouseEnabled=false;

但如果我这样使用它,我必须为所有按钮编写脚本,我有很多。所以我认为这会给我的计划带来负担。

2 个答案:

答案 0 :(得分:1)

不仅mouseEnabled,您还必须禁用C的mouseChildren属性。

A.B.C.mouseChildren = false;

答案 1 :(得分:0)

我假设您已经有一个自定义类来存储您的子MovieClip,只需要一个函数来检查它是否是正确的子项,以及它是否在子项上调用相同的函数。 EG:

public class ClipMovie extends MovieClip
{
    private var _Child:ClipMovie;

    public function DisableButtonsAt(int childIndex, int currentIndex):void
    {
            if(childIndex + 1 == currentIndex)
            {
                someButton.mouseEnabled = false;
            }
            else if(_Child != null)
            {
                _Child.DisableButtonsAt(childIndex, currentIndex + 1);
            }
            else
            {
                throw new Error("Unable to find child, cannot disable buttons.");
            }
    }
}