i am trying to make a function to deal easily with text formatting. there seems to be a problem as the text in the textfield is not visible. all the parameters and attributes are set properly when i trace, i can even copy the text from the textfield, but i cannot see it.
/**
* Description
* @author Mat Janson Blanchet
* @version 0.1
*/
package {
// imports
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
// class definition
public class Main extends MovieClip {
// variables
// constructor
public function Main () {
var textfield:TextField = new TextField ();
var text:String = "<p>some paragraph 01</p><p>some paragraph 02</p><p>some paragraph 03</p>";
format (text, textfield, { width:160, height:80, selectable:true, multiline:true, border:true }, false, { font:"_arial", size:16, color:0x000000 } );
addChild (textfield);
}
// events
// functions
public function format (
text :String, // text to display
textfield :TextField, // textfield to target
textfieldParams :Object, // textfield parameters
textfieldIsHTML :Boolean, // whether or not the textfield should display in html
formatParams :Object // format parameters
) :void {
trace ("textfield parameters: ");
// loop through the parameters name and associate the proper value to the textfield
for (var txtfldParamName:String in textfieldParams) {
textfield[txtfldParamName] = textfieldParams[txtfldParamName];
trace (textfield + "[" + txtfldParamName + "] = " + textfieldParams + "[" + txtfldParamName + "]");
trace ("textfield[txtfldParamName]: " + textfield[txtfldParamName]);
trace ("textfieldParams[txtfldParamName]: " + textfieldParams[txtfldParamName]);
}
trace ("textfield: " + textfield)
trace ("");
trace ("format parameters: ");
// loop through the parameters name and associate the proper value to the textfield
var format:TextFormat = new TextFormat ();
for (var fmtParamName:String in formatParams) {
format[fmtParamName] = formatParams[fmtParamName];
trace (format + "[" + fmtParamName + "] = " + formatParams + "[" + fmtParamName + "]");
trace ("format[fmtParamName]: " + format[fmtParamName]);
trace ("formatParams[fmtParamName]: " + formatParams[fmtParamName]);
}
trace ("format: " + format);
trace ("");
trace ("textfieldIsHTML: " + textfieldIsHTML);
trace ("text: " + text);
// input text into textfield
if (!textfieldIsHTML) {
textfield.text = text;
trace ("textfield.text: " + textfield.text);
} else {
textfield.htmlText = text;
trace ("textfield.htmlText: " + textfield.htmlText);
}
textfield.embedFonts = true;
trace ("textfield.embedFonts: " + textfield.embedFonts);
textfield.setTextFormat (format);
}
}
}
does anyone know what i forgot or did not do right? i also enclosed the fla and the as if it helps anyone