# Xml, attachMovie and createTextField

**URL:** https://forum.kirupa.com/t/xml-attachmovie-and-createtextfield/67631
**Category:** Uncategorized
**Created:** [October 18, 2004, 10:54am UTC](https://forum.kirupa.com/t/xml-attachmovie-and-createtextfield/67631 "2004-10-18T10:54:39Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Mona](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Mona](https://forum.kirupa.com/u/Mona)
#### Post date: [October 18, 2004, 10:54am UTC](https://forum.kirupa.com/t/xml-attachmovie-and-createtextfield/67631/1 "2004-10-18T10:54:39Z")

</div>

ok, here we go again… i am back working on this file and, again, stuck with it. Some time ago Asish very kindly pointed me in the right direction, but i haven’t been able to properly solve my problem. If anyone could give me some pointers that would be great. I’ll try and explain…

I have an XML file i load into Flash. The xml gives me a set of text headers and text descriptions. Something like this:

\<main\>  
\<item\>  
\<header\>header 1\</header\>  
\<desc\>description 1\</desc\>  
\</item\>  
\<item\>  
\<header\>header 2\</header\>  
\<desc\>description 2\</desc\>  
\</item\>  
\</main\>

I need to position these headers&descriptions in a column underneath each other, so i need to know their height in order to position the following text field in the right \_y. Any of these headers and descriptions could vary in height.

I am placing each item (header&description) in a movie “newi” with attachMovie. And because it might all need to have a scroll bar, it’s all contained in another movie called itemContainer.

function loadXML(loaded) {  
if (loaded) {  
myXML = this.firstChild.childNodes;  
itemContainer.\_x = 20;  
itemContainer.\_y = 20;

```
	for (var i = 0; i&lt;myXML.length; i++) {
		item = itemContainer.attachMovie("newi", "newi"+i, i);
		itemContainer.item.header.text = this.firstChild.childNodes*.childNodes[0].firstChild.nodeValue;
		itemContainer.item.description.text = this.firstChild.childNodes*.childNodes[1].firstChild.nodeValue;
		itemContainer.item._x = 80;
		itemContainer.item._y = 100+110*i;
		
	}
	
}

```

}  
xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.onLoad = loadXML;  
xmlData.load(“myXML.xml”);

inside newi I only dynamically create the text fields with createtextField. I think this is the only way I can then read the height of the text fields, is this correct? I have something like this in newi

this.createTextField(“header”, this.getNextHighestDepth(), 10, 10, 140, 20);  
this.createTextField(“description”, this.getNextHighestDepth(), 10, 40, 140, 20);  
header.multiline = true;  
header.border = true;  
header.textColor = 0xffffff;  
header.autoSize = true;  
header.wordWrap = true;  
description.multiline = true;  
description.border = true;  
description.textColor = 0xffffff;  
description.autoSize = true;  
description.wordWrap = true;

And well, it is not working. I’ve been over it so many times i can’t think about it very clearly anymore! Ⓜ

Attached is a fla with this. I don’t know if maybe i am not approaching this in the right way. If anyone could give me a hand it would be much much appreciated!

thank you

:}
