dcster2001
11-09-2007, 04:01 PM
I've created a textfield in a TextBox class that will display textfield.text properly, but I am having trouble displaying textfield.htmlText. Here's what I've got:
private var txtfld:TextField;
// Create the TextField
private function createTextField ():void {
txtfld = new TextField();
txtfld.width = 378;
txtfld.height = 244;
txtfld.embedFonts = true;
txtfld.antiAliasType = AntiAliasType.ADVANCED;
txtfld.gridFitType = GridFitType.PIXEL;
txtfld.selectable = false;
txtfld.wordWrap = true
txtfld.htmlText = "<p align='center'><b>TEXT TEST</b>";
// Apply formatting
txtfld.setTextFormat(format);
// Add textfield to display list
addChild(txtfld);
}
"TEXT TEST" displays as it should.
However, when I try to add html-formatted text outside of the txtfld creation function via setHtmlText("SomeHTMLString") (or even explicitly in the TextBox() constructor body via txtfld.htmlText = "SomeHTMLString" after the textfield is created) it doesn't display. Here's the setHtmlText() code:
// Assign htmlText to txtfld
public function setHtmlText (txt:String):void {
txtfld.htmlText = txt;
}
Is there some other sort of formatting that I need to apply to get it to work? I even included a <FONT FACE="Arial"> tag to ensure the embedded font was accessible, but it still doesn't display any htmlText outside of the txtfld creation function.
A setText method does work, however:
// Assign text to txtfld
public function setText (txt:String):void {
txtfld.text = txt;
// Apply formatting
txtfld.setTextFormat(format);
}
Any help is appreciated.
private var txtfld:TextField;
// Create the TextField
private function createTextField ():void {
txtfld = new TextField();
txtfld.width = 378;
txtfld.height = 244;
txtfld.embedFonts = true;
txtfld.antiAliasType = AntiAliasType.ADVANCED;
txtfld.gridFitType = GridFitType.PIXEL;
txtfld.selectable = false;
txtfld.wordWrap = true
txtfld.htmlText = "<p align='center'><b>TEXT TEST</b>";
// Apply formatting
txtfld.setTextFormat(format);
// Add textfield to display list
addChild(txtfld);
}
"TEXT TEST" displays as it should.
However, when I try to add html-formatted text outside of the txtfld creation function via setHtmlText("SomeHTMLString") (or even explicitly in the TextBox() constructor body via txtfld.htmlText = "SomeHTMLString" after the textfield is created) it doesn't display. Here's the setHtmlText() code:
// Assign htmlText to txtfld
public function setHtmlText (txt:String):void {
txtfld.htmlText = txt;
}
Is there some other sort of formatting that I need to apply to get it to work? I even included a <FONT FACE="Arial"> tag to ensure the embedded font was accessible, but it still doesn't display any htmlText outside of the txtfld creation function.
A setText method does work, however:
// Assign text to txtfld
public function setText (txt:String):void {
txtfld.text = txt;
// Apply formatting
txtfld.setTextFormat(format);
}
Any help is appreciated.