AnimAtecc Canvas调用功能



我正在尝试将我从actionscript 3制成的代码更改为html5 canvas。我对创建的调用函数有疑问,例如:

function cleanSelection(){
    this.a1.visible = true;
    this.sa1.visible = false;
    this.a2.visible = true;
    this.sa2.visible = false;
}
function maxSelection(count){
    cleanSelection();
    count = 0;
    return count;
}

我想在下面使此功能能够调用maxSelection(),该功能调用cleanSelection()

this.a1.addEventListener("click", fl_Click.bind(this));
function fl_Click()
{
   this.sa1.visible = true;
   this.a1.visible = false;
   count++;
   if(count >= 2){
       count = maxSelection(count);
   }
}

如何称呼这些功能?

您应该将"绑定(this)"放在所有方法中:

function cleanSelection(){
   this.a1.visible = true;
   this.sa1.visible = false;
   this.a2.visible = true;
   this.sa2.visible = false;
}
function maxSelection(c){
   cleanSelection.bind(this)();
   c= 0;
   return c;
}
var count = 0;
this.a1.addEventListener("click", fl_Click.bind(this));
function fl_Click() {
  this.sa1.visible = true;
  this.a1.visible = false;
  count++;
  if(count >= 2){
     count = maxSelection.bind(this)(count);
  }

}

相关内容

  • 没有找到相关文章

最新更新