# Adding html to array content

**URL:** <https://forum.kirupa.com/t/adding-html-to-array-content/265460>\
**Category:** flash\
**Created:** [July 9, 2008, 6:24am UTC](https://forum.kirupa.com/t/adding-html-to-array-content/265460 "2008-07-09T06:24:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharkb8](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@sharkb8](https://forum.kirupa.com/u/sharkb8)\
**Post date:** [July 9, 2008, 6:24am UTC](https://forum.kirupa.com/t/adding-html-to-array-content/265460/1 "2008-07-09T06:24:54Z")

</div>

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

```auto
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!

---

<div class="post-metadata">

**Author:** ![shaji](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@shaji](https://forum.kirupa.com/u/shaji)\
**Post date:** [July 9, 2008, 7:26am UTC](https://forum.kirupa.com/t/adding-html-to-array-content/265460/2 "2008-07-09T07:26:06Z")

</div>

I hope this is what you need

```auto

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

```auto

bob
larry
moe
charlie
john
joe
jesus
mitch
sarah
steph

```

---

<div class="post-metadata">

**Author:** ![sharkb8](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@sharkb8](https://forum.kirupa.com/u/sharkb8)\
**Post date:** [July 9, 2008, 6:10pm UTC](https://forum.kirupa.com/t/adding-html-to-array-content/265460/3 "2008-07-09T18:10:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![shaji](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@shaji](https://forum.kirupa.com/u/shaji)\
**Post date:** [July 10, 2008, 3:04am UTC](https://forum.kirupa.com/t/adding-html-to-array-content/265460/4 "2008-07-10T03:04:51Z")

</div>

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

```auto

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](http://google.com)

---

<div class="post-metadata">

**Author:** ![sharkb8](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@sharkb8](https://forum.kirupa.com/u/sharkb8)\
**Post date:** [July 10, 2008, 4:21pm UTC](https://forum.kirupa.com/t/adding-html-to-array-content/265460/5 "2008-07-10T16:21:35Z")

</div>

That’s brillant man. I really appreciate it.
