# Dynamic placement of movieclip loaded with XML

**URL:** <https://forum.kirupa.com/t/dynamic-placement-of-movieclip-loaded-with-xml/148924>\
**Category:** flash\
**Created:** [May 24, 2005, 5:56pm UTC](https://forum.kirupa.com/t/dynamic-placement-of-movieclip-loaded-with-xml/148924 "2005-05-24T17:56:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnnie2times](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@johnnie2times](https://forum.kirupa.com/u/johnnie2times)\
**Post date:** [May 24, 2005, 5:56pm UTC](https://forum.kirupa.com/t/dynamic-placement-of-movieclip-loaded-with-xml/148924/1 "2005-05-24T17:56:26Z")

</div>

Hi all,  
My first post on this eminent forum! Hopefully i can contribute to it soon aswell, but first mayby there is someone in here that can help me! 🙂

I have a videoplayer in which i load video interviews via XML into flash.  
I dynamically create the “question” buttons via attachMovie.

My problem is that the length of each questions text can be different, so i need to place the questions underneath eachother dynamically depending on how large the textfield becomes. The “buttons”/text have a given/static width off 330px so they need to grow by height dynamically but with 10px beeteween each question.

It is the

```auto
newBut._y = (i*newBut.but_txt._height)+75;

```

that is puzzeling me!

Anyway, here is the code I am using:

```auto
myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(ok) {
	if (ok) {
		//trace ('data loaded');
		//trace (this.firstChild.firstChild.attributes.text);
		allData = this.firstChild.childNodes;
		for (i=0; i<allData.length; i++) {
			//trace(allData*.attributes.text);
			newBut = _root.attachMovie('butTemp', 'but'+i, i);
			newBut.but_txt.autoSize = true;
			newBut._x = 170;
			//newBut._y=(i*30)+75;
			newBut._y = (i*newBut.but_txt._height)+75;
			
			newBut.but_txt.text = allData*.attributes.text;
			//trace(allData*.firstChild.firstChild)
			newBut.myHeading = allData*.firstChild.firstChild;
			//trace(allData*.firstChild.nextSibling.firstChild)
			newBut.myVideo = allData*.firstChild.nextSibling.firstChild;
			
			newBut.onRelease = function() {
				heading_txt.text = this.myHeading;
				
				content_txt.text = this.myVideo;
				
				netStream.play("media/"+this.myVideo+".flv");
				my_video.play_butt._visible = false;
				my_video.pause_butt._visible = true;
				
			};
		}
	} else {
		trace('error');
	}
};
myXML.load('video.xml');

```

Hopefully someone can help me

Best Regards

/John
