Skip to main content
vlceversa
Known Participant
June 8, 2013
Question

Setting text property of a TextField

  • June 8, 2013
  • 1 reply
  • 773 views

Ok, I'm kinda lost, I have a TextField and I want to set it's text property to a new text. But when I do it, the TextFild.text gets set, but is not beeing displayed.

the code so far

private var tf:TextField;

public function setGame():void {

     if (upcoming == true) {

          tf = new TextField();

          var tFormat:TextFormat = new TextFormat();

          var tFont:Font = new Dota2();

          tFormat.font = tFont.fontName;

          tFormat.size = 48;

          tFormat.color = 0x323232;

          tf.x = 230;

          tf.autoSize = TextFieldAutoSize.CENTER;

          tf.text = "Next Match In"; // thats beeing displayed

          tf.setTextFormat(tFormat);

          tf.embedFonts = true;

          addChild(tf);

     }

}

private function timerUp(e:Event):void {

     tf.text = "Next Match Is About To Start"; // text just disappears

     removeChild(clock); // this gets executed

}

Maybe I do something wrong with the order of the code or something.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
June 8, 2013

does any code execute after timerUp is called?

vlceversa
vlceversaAuthor
Known Participant
June 8, 2013

Umm, not in this Class I think, the timerUp function gets called when I dispatch the event from a timer class when the timer has reached zero. It removes the clock from the stage, so there is no 00:00:00 being displayed. And I just wanted the text to change to this new one.

kglad
Community Expert
Community Expert
June 8, 2013

then your textfield's not wide enough to contain your text or, it is wide enough but your stage is not wide enough to show the text to the right of the stage.

to determine which, add:

tf.width=1000;