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 回答