以下のコードサンプルを短くして読みやすくしました。ここでは擦れている:私は、文字のa - zを含むムービークリップの全体の束を作成します。これらのムービークリップは、「levelTwo」という名前の親ムービークリップの子です。levelTwoは、そのレベルのロジックマネージャの一種です。子オブジェクトと親関数の間の1069エラーの解決
クリックすると、評価のためにlevelTwoにデータが送信されます(これはHangmanです)。問題は、クリックすると1069エラーが発生することです。 LetterButtonのevent.target.parentビットを追加するまで、1061のエラーが発生しました。
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
public class LetterButton extends MovieClip {
var buttonText:String;
public function LetterButton(lText:String,objX:int,objY:int)
{
trace ("Creating new button");
x = objX;
y = objY;
buttonText = lText;
letterText.text = buttonText;
this.stop();
addEventListener(MouseEvent.MOUSE_OVER,onMouseOver);
addEventListener(MouseEvent.MOUSE_OUT,onMouseOut);
this.addEventListener(MouseEvent.CLICK,onMouseClick);
}
private function onMouseOver(event:Event):void
{
gotoAndStop(2);
letterText.text = buttonText;
//trace ("You're over me and my text is " + buttonText);
}
private function onMouseOut(event:Event):void
{
gotoAndStop(1);
letterText.text = buttonText;
//trace ("You're out of me and my text is " + buttonText);
}
private function onMouseClick(event:Event):void
{
trace ("I am clicked and I am " + buttonText);
event.target.parent.checkGuess(buttonText);
}
}
} そしてlevelTwoから該当ビット:私はここに魔法を見ない
public function checkGuess(guess:String):void
{ //Check to see if the guess matches the string
trace ("Guess: "+guess);
for(var i:int=0;i<answer.length;i++)
{
if(guess == answer.charAt(i))
{
censoredAnswer[i] = guess;
trace ("Got one right");
answerField.text = answerRedisplay(); //Do it now or it won't update for the check
}
}
if (answerField.text == answer)
{
setWin();
}
}
これを修正するための管理:MovieClip(親).checkGuess(buttonText); – GilloD