When i access "numerText[i].text()" in function of circles[i]'s on click event handler firebug prompts error:"numberText[i] is undefined ". Actually I want to assign the text returned by calling "numerText[i].text()" to variable "score"
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 help me