# XML - Dynamic text fields not working

**URL:** <https://forum.kirupa.com/t/xml-dynamic-text-fields-not-working/265515>\
**Category:** flash\
**Created:** [July 9, 2008, 7:22pm UTC](https://forum.kirupa.com/t/xml-dynamic-text-fields-not-working/265515 "2008-07-09T19:22:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![BuG56](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@BuG56](https://forum.kirupa.com/u/BuG56)\
**Post date:** [July 9, 2008, 7:22pm UTC](https://forum.kirupa.com/t/xml-dynamic-text-fields-not-working/265515/1 "2008-07-09T19:22:06Z")

</div>

Hello everyone, I’ve got a bit of a problem with dynamically created text fields. I want to have the required effect :

The flash file loads the xml file (this works fine) and is able to read all nodes and attributes (yup, works too) and then create a certain amount of dynamic text fields populated with data from an attribute(not working so well…) Heres my code :

```auto

var news = new XML();
news.ignoreWhite = true;
news.load("newsdata.xml");
function process(no)
{
    if(_root.news.firstChild.nodeName =="xml")
    {
        titleList = new Array();
        for(i=0;i<_root.news.firstChild.childNodes.length;i++)
        {
            
            nameref=["news_title_"+i];
            this.createTextField(nameref, 1, 20, 20*i, 300, 100);
            titleList*=_root.news.firstChild.childNodes*.attributes.newsTitle;
            with(nameref)
            {
                type = "dynamic";
                border = true;
                background = false;
                multiline = true;
                selectable = true;
                wordWrap = true;
                font = "Verdana";
                size = 12;
                color = 0x9C0000;
                bold = true;
                align = "left";
                text=titleList*;            
            }
        }
    }
}
news.onLoad = function(success:Boolean) {
    if (success) {
        process(0);
    } else {
        //Error
    }
};

```

I’m not going to post the whole xml file because that’s redundant, I’ll just post it’s setup :

```auto

<xml>
<pr newsTitle="title" etc="" etc="">
info
</pr>
<pr>
</pr>
<pr>
</pr>
</xml>

```

So, I am able to retrieve the values of newsTitle, and it reads the amount of tags just fine, but it does not populate the text fields, I’m not sure if it even creates them because the with statement should put a border around them (no visible borders appear) and Debug\>List Objects produces only this :

```auto

Edit Text: Target="_level0.news_title_2" Variable= Visible=true Text = "

```

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![BuG56](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@BuG56](https://forum.kirupa.com/u/BuG56)\
**Post date:** [July 9, 2008, 7:47pm UTC](https://forum.kirupa.com/t/xml-dynamic-text-fields-not-working/265515/2 "2008-07-09T19:47:37Z")

</div>

Well, I fixed the problem of only one of the text feilds being created. (They were all on the same z index)

```auto
 
this.createTextField(nameref, 1, 20, 20*i, 300, 100);
//changed to
this.createTextField(nameref, 1+i, 20, 20*i, 300, 100);

```

They’re still not being populated, and they’re still not getting the properties from the with()

---

<div class="post-metadata">

**Author:** ![BuG56](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@BuG56](https://forum.kirupa.com/u/BuG56)\
**Post date:** [July 9, 2008, 7:53pm UTC](https://forum.kirupa.com/t/xml-dynamic-text-fields-not-working/265515/3 "2008-07-09T19:53:29Z")

</div>

Haha! Fixed it.

```auto

with(nameref)
// Should have been referenced as
with(_root[nameref])

```

Thanks for the help I’m sure you guys would have given.

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [July 9, 2008, 8:02pm UTC](https://forum.kirupa.com/t/xml-dynamic-text-fields-not-working/265515/4 "2008-07-09T20:02:54Z")

</div>

I definenately would have 😃

---

<div class="post-metadata">

**Author:** ![prg9](https://avatars.discourse-cdn.com/v4/letter/p/8dc957/32.png) [@prg9](https://forum.kirupa.com/u/prg9)\
**Post date:** [July 9, 2008, 8:26pm UTC](https://forum.kirupa.com/t/xml-dynamic-text-fields-not-working/265515/5 "2008-07-09T20:26:03Z")

</div>

> [@randomagain;2355865](#):
>
> I definenately would have

I “definitely” believe you. :beam:
