# Problem adding multiple lines to xml lead dynamic buttons

**URL:** <https://forum.kirupa.com/t/problem-adding-multiple-lines-to-xml-lead-dynamic-buttons/315625>\
**Category:** Uncategorized\
**Created:** [October 30, 2010, 3:16pm UTC](https://forum.kirupa.com/t/problem-adding-multiple-lines-to-xml-lead-dynamic-buttons/315625 "2010-10-30T15:16:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![daymes](https://avatars.discourse-cdn.com/v4/letter/d/8baadc/32.png) [@daymes](https://forum.kirupa.com/u/daymes)\
**Post date:** [October 30, 2010, 3:16pm UTC](https://forum.kirupa.com/t/problem-adding-multiple-lines-to-xml-lead-dynamic-buttons/315625/1 "2010-10-30T15:16:14Z")

</div>

Hi there,

I have been following a tutorial to make an xml based gallery, just having a bit of a problem adding multiple lines of text to buttons which have been created dynamically.

I have set it up with a dynamic text box and button, which reproduce for every xml node, all good. When the text over runs the text box area, it creates a new line, which is great, the problem is the next button is created by adding a certain amount to the Y axis of the previous button, so there is overlap where the buttons have more than one line of text.

I sort of bodged a solution, by adding blank lines to the names below, eg

\<?xml version=“1.0” encoding=“UTF-8”?\>  
\<MENUS\>  
\<MENU name=“Glass Book with Cat’s Whiskers” link="" description="" file=“lbook.swf”/\>  
\<MENU name="  
Glass Hand Tool with Cat’s Whiskers" link="" description="" file=“ltool.swf”/\>  
\<MENU name="

Gold Broom" link=“[http://www.slingshot.co.uk](http://www.slingshot.co.uk)” description="" file=“lbroom.swf”/\>  
\<MENU name="

Glass Plug" link="" description="" file=“lplug.swf”/\>  
\<MENU name="

Glass Brush with Cat’s Whiskers" link="" description="" file=“lbrush.swf”/\>  
\<MENU name="

Bronze Dress" link="" description="" file=“ldress.swf”/\>  
\</MENUS\>  
but this messes with the button alignment, which starts according to the first line of the menu name, so for example the last button has 3 blank lines before it making the roll over miles away from the actual text.  
I’ve tried putting /n  
//n and \<b\> where I want the breaks but thats not working (used html text for the last one) do I need to add something else to the xml, or is it in the AS? I’m using as2, here is the (relevant) code :  
function SS\_Arrays() {  
for (var count = 0; count \< \_root.projectCount; count++) {  
var nodeObj = objXML.firstChild.childNodes[count];  
namesArray[count] = nodeObj.attributes.name;  
descriptionsArray[count] = nodeObj.attributes.description;  
linksArray[count] = nodeObj.attributes.link;  
filesArray[count] = nodeObj.attributes.file;  
headLine.wordWrap = true;  
}  
// run the function to create the thumbnail and list view buttons  
SS\_createButtons();  
}  
////////////////////////////////////////////////////////////////////// ///////////////////  
function SS\_createButtons() {  
// First of all we want to hide the master button on the stage (btn\_projects\_main)  
// because we’ll be making duplicates of it in the next part of the function  
\_root.btn\_projects\_main.\_visible = 0;  
// Work out the X and Y positions of the main button so our new buttons start in the same place  
// (Which means where ever you position the main button is where the navigation will start).  
btn\_xPos = \_root.btn\_projects\_main.\_x;  
btn\_yPos = \_root.btn\_projects\_main.\_y;  
// Set the distances between your buttons and the number of rows  
btn\_xDistance = 140;  
btn\_yDistance = 24;  
btn\_numOfRows = 25;  
// This figure is used to work out when to start a new column of buttons  
btn\_yMax = btn\_yPos + ((btn\_numOfRows - 1) \* btn\_yDistance);  
// Loop through the projects array and create a button for each one by duplicating the original.  
for (count = 0; count \< \_root.projectCount; count++) {  
duplicateMovieClip(\_root.btn\_projects\_main, “btn\_projects” + count, count);  
// As the button is created, set it’s X, Y & text properties  
\_root[“btn\_projects” + count].\_x = btn\_xPos;  
\_root[“btn\_projects” + count].\_y = btn\_yPos;  
\_root[“btn\_projects” + count].text = namesArray[count];  
// set the X position for the next button  
if(btn\_yPos == btn\_yMax){  
// if the last buttons was the last row in the column (based on it’s Y position) then start a new column  
// by resetting the Y position and adding 140px (btn\_xDistance) to the the X position.  
btn\_xPos = btn\_xPos + btn\_xDistance;  
btn\_yPos = \_root.btn\_projects\_main.\_y;  
} else {  
// if it’s not the last one in a row, simply move it along the Y axis.  
btn\_yPos = btn\_yPos + btn\_yDistance;  
}  
}  
// Load the first project (number 0) to avoid an empty screen  
SS\_load\_project(0);  
// Make the first project button highlighted  
tellTarget(\_root.btn\_projects0){  
gotoAndPlay(3);  
}  
// Set the current button variable so we know which button to switch off when another one is pressed  
\_root.curButton = “0”;  
}  
Sorry if I’ve overloaded you with the text - I’m sure there must be a simple answer to this ?stion, I can post the files if that helps at all.
