AS3 - 禁用除一个按钮之外的所有按钮

时间:2011-10-05 19:27:35

标签: actionscript-3

在上传过程中,我需要禁用舞台上的所有按钮,除了取消上传过程的按钮。 我尝试了这个,但“mybutton”继续被禁用:

stage.mouseChildren = false;
mysection.mybutton.mouseChildren = true

怎么做?

1 个答案:

答案 0 :(得分:-1)

下面的内容可能会对您有所帮助。但是你必须检查语法错误,没有时间进行检查......如果你不能解决问题,请提出任何问题。

function findMyButton(doc:DisplayObjectContainer , n:String):void{
  for(var i:int=0; i<doc.numChildren; i++)
  {
    var btn:DisplayObjectContainer = this.getChildAt(i) as DisplayObjectContainer;

    if(btn && btn.numChildren > 0){
       findMyButton(btn , n);
    }

      if(btn.name =="btn_upload")
      {
        btn.mouseEnabled = true;
      }
      else
      {
        btn.mouseEnabled = false;
      }

  }

}

// This ll allow you to disable or enable all your objects
// so you can activate the button you like after you call this method.
function conrolmyButtons(doc:DisplayObjectContainer , b:Boolean):void{
  for(var i:int=0; i<doc.numChildren; i++)
  {
    var btn:DisplayObjectContainer = this.getChildAt(i) as DisplayObjectContainer;
    if(btn && btn.numChildren > 0){
       findMyButton(btn , n);
    }
    btn.mouseEnabled = b;
  }

}