flash canvasめも.
もう1つはまった。functionの中から、たとえば、this.textScore.textの中身を更新しようとして、this.textScore.text=”何かしらの値”としても、Uncaught TypeError: Cannot set property ‘text’ of undefinedとされ、更新されないです。
なので、おまじない?なのか、var that = this;として、記述し直します。
that.textScore.text=”何かしらの値”
あと、自分でjsを追加する時は定義(var)を忘れずに。
以下、サンプル。
var count_score = 0; var that = this; function jankenEvent() { kekka = Math.floor(Math.random() * 3); switch (kekka) { case 0: kekka_text = "ぐー"; count_score = count_score + 2; that.text_score.text = count_score; break; case 1: kekka_text = "ちょき"; count_score = count_score + 1; that.text_score.text = count_score; break; case 2: kekka_text = "ぱー"; count_score = count_score + 3; that.text_score.text = count_score; break; default: break; } console.log(kekka); console.log(kekka_text); console.log(count_score); }