当我在click [i]的函数中访问“numerText [i] .text()”时,单击事件处理程序firebug会提示错误:“numberText [i]未定义”。其实我想把调用“numerText [i] .text()”返回的文本分配给变量“得分”
var score=0;
for(var i=0;i<3;i++){
//adding number text
numberText[i]=new Kinetic.Text({
x:circles[i].getX(),
y:circles[i].getY(),
text:i,
fill:'white',
name:'nText'
});
group[i].add(circles[i],numberText[i]);
layer.add(group[i]);
//zn click circles
circles[i].on('click',function(){
score=numberText[i].text(); //here "numberText[i] is undefined" error fires
scoreText.text(score);
layer.draw();
});
}
Plz帮帮我