Use the x and y property's of the Text Field to position the text on the button?
If there's something I'm missing ill update my answer.
Question
I'd like to add text to a working button. Currently, the code below prints the text at 0,0 rather than on the sprite button.
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);
Additionally, I'd like to add code to the listener below to have the button text reflect the state of the boolean doSound.
private function sound_CLICK (event:MouseEvent):Void {
doSound = !doSound;
// swap sprite button text Sound on/Sound off
}
Solution
Use the x and y property's of the Text Field to position the text on the button?
If there's something I'm missing ill update my answer.