そのため、フラッシュゲームで再起動ボタンを精力的に操作した後でも、ボタンはクリックを登録しません。
ボタンのコードは次のとおりです。 trace() フラグが表示されないため、問題は MouseEvent.CLICK にあると思います。
package
{
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.ui.Mouse;
/**
* ...
* @author Andrew Xia
*/
public class RestartButton extends SimpleButton
{
public function RestartButton(setX:Number, setY:Number)
{
this.x = setX;
this.y = setY;
addEventListener(MouseEvent.CLICK, onClick);
}
public function onClick(event:MouseEvent):void
{
trace("HELLO!");
dispatchEvent( new NavigationEvent( NavigationEvent.RESTART ));
}
}
}
ボタンを追加した画面のコードは次のとおりです。
package
{
import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.ui.Mouse;
/**
* ...
* @author Andrew Xia
*/
public class GameOverScreen extends MovieClip
{
public var restartButton:RestartButton;
public var scoreLabel:TextField;
public var scoreBox:TextField;
public function GameOverScreen()
{
Mouse.show();
restartButton = new RestartButton(0, 108);
addChild(restartButton);
var textFormat = new TextFormat();
textFormat.size = 54;
scoreLabel = new TextField();
scoreLabel.x = -185;
scoreLabel.y = -36.75;
scoreLabel.height = 73.5;
scoreLabel.width = 185;
scoreLabel.text = "SCORE: ";
scoreLabel.textColor = 0xFFFFFF;
scoreLabel.setTextFormat(textFormat);
addChild(scoreLabel);
scoreBox = new TextField();
scoreBox.x = 0;
scoreBox.y = -36.75;
scoreBox.height = 73.5;
scoreBox.width = 143;
scoreBox.text = (String)(Main.playerScore);
scoreBox.textColor = 0xFFFFFF;
scoreBox.setTextFormat(textFormat);
addChild(scoreBox);
}
}
}
助けてください、この問題は私を夢中にさせています。おそらく私の側の本当にばかげたエラーだと確信していますが、皆さんが私を助けてくれれば非常に感謝しています.