Adding html to array content

I’m trying to put html breaks to this array so that the set of names are rendered downwards instead of side by side:

var pageContent:Array = ["bob", "larry", "moe", "charlie", "john", "joe", "jesus", "mitch", "sarah", "steph", "susan", "jimmy"];

var txtFmt:TextFormat = new TextFormat();
txtFmt.font = "Helvetica";
txtFmt.bold = true;
txtFmt.size = 18;

var txtFld:TextField= new TextField();
txtFld.autoSize = TextFieldAutoSize.LEFT;
txtFld.multiline= txtFld.wordWrap = true;
txtFld.defaultTextFormat= txtFmt;
for(var i:Number=0; i < 10 ; i++)
{
    
    txtFld.appendText( pageContent*);
}

addChild(txtFld);

In php it’s just as simple as echoing out html tags in the for loop but I dont get it in AS3. Any help is greatly appreciated!

I hope this is what you need



var pageContent:Array = ["bob", "larry", "moe", "charlie", "john", "joe", "jesus", "mitch", "sarah", "steph", "susan", "jimmy"];

var txtFmt:TextFormat = new TextFormat();
txtFmt.font = "Helvetica";
txtFmt.bold = true;
txtFmt.size = 18;

var txtFld:TextField= new TextField();
txtFld.autoSize = TextFieldAutoSize.LEFT;
txtFld.multiline= txtFld.wordWrap = true;
txtFld.defaultTextFormat= txtFmt;
for(var i:Number=0; i < 10 ; i++)
{
    
    txtFld.appendText( pageContent*+"
");
}

addChild(txtFld);


Output is as below


bob
larry
moe
charlie
john
joe
jesus
mitch
sarah
steph

Nice! How would you add html within that array? Im trying to get these names to be links. I appreciate your help James.

Adding “a” tag to the array content should work, textfield type should be htmlText.



var pageContent:Array = ["<a href ='http://www.google.com/'>bob</a>", "<a href ='http://www.google.com/'>larry</a>", "moe", "charlie", "john", "joe", "jesus", "mitch", "sarah", "steph", "susan", "jimmy"];

var txtFmt:TextFormat = new TextFormat();
txtFmt.font = "Helvetica";
txtFmt.bold = true;
txtFmt.size = 18;

var txtFld:TextField= new TextField();
txtFld.autoSize = TextFieldAutoSize.LEFT;
txtFld.multiline= txtFld.wordWrap = true;
txtFld.defaultTextFormat= txtFmt;
txtFld.type
for(var i:Number=0; i < 10 ; i++)
{
    txtFld.htmlText += pageContent*+"
"
}

addChild(txtFld);


Once you run the fla, first two names would be link leading to google.com

That’s brillant man. I really appreciate it.