I have a textDisplay class that i want to instantiate in another class and set the text property with the function setText. It works but the problem is that the textformat stops working when I call setText(_theText); if i comment this out the textformat works. how can i make the textformat update with _theText.
package view
{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
public class TextDisplay extends MovieClip{
private var textFormat:TextFormat = new TextFormat();
private var _OxLabel:TextField = new TextField();
private var _theText:String = "100";
public function TextDisplay(){
textFormat.font = "Arial";
textFormat.size = 21;
textFormat.bold = true;
textFormat.color = 0xffffff;
_OxLabel.text = _theText;
_OxLabel.setTextFormat(textFormat);
_OxLabel.selectable = false;
_OxLabel.mouseEnabled = false;
addChild(_OxLabel);
}
private function setText(_theText){
_OxLabel.text = _theText;
}
public function set theText(value:String):void {
_theText = value;
setText(_theText);
}
}
}
Thanks!