0

作業中のボタンにテキストを追加したいと思います。現在、以下のコードはスプライト ボタンではなく 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

     } 
4

1 に答える 1

0

テキスト フィールドの x プロパティと y プロパティを使用して、ボタンにテキストを配置しますか?

不足しているものがあれば、回答を更新してください。

于 2014-04-30T22:04:19.567 に答える