作業中のボタンにテキストを追加したいと思います。現在、以下のコードはスプライト ボタンではなく 0,0 にテキストを出力します。
soundButton.graphics.beginFill(0xFFCC00);
soundButton.graphics.drawRect(0,900, 200, 50);
soundButton.graphics.endFill();
this.addChild(soundButton);
var soundtext:TextField = new TextField();
soundtext.text ="Sound On"; // default value
soundButton.addChild(soundtext);
soundButton.addEventListener( MouseEvent.CLICK,sound_CLICK);
さらに、下のリスナーにコードを追加して、ボタンのテキストにブール値の doSound の状態を反映させたいと思います。
private function sound_CLICK (event:MouseEvent):Void {
doSound = !doSound;
// swap sprite button text Sound on/Sound off
}