# Newbie Button Reference Probs Help Appreciated

**URL:** <https://forum.kirupa.com/t/newbie-button-reference-probs-help-appreciated/191737>\
**Category:** flash\
**Created:** [June 22, 2006, 4:24pm UTC](https://forum.kirupa.com/t/newbie-button-reference-probs-help-appreciated/191737 "2006-06-22T16:24:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lowey](https://avatars.discourse-cdn.com/v4/letter/l/e36b37/32.png) [@lowey](https://forum.kirupa.com/u/lowey)\
**Post date:** [June 22, 2006, 4:24pm UTC](https://forum.kirupa.com/t/newbie-button-reference-probs-help-appreciated/191737/1 "2006-06-22T16:24:05Z")

</div>

Problem is the actual reference to the button itself. When I run a trace on item\_mc it reveals that the buttons are named main\_btn0 thru to main\_btn4 as expected. Problem is that when I use the reference main\_btn0 and so on nothing happens. However if I use a reference to just main\_btn the buttons work but action is not assigned to any particular button?? Why???

var track\_xml = new XML();  
track\_xml.ignoreWhite = true;  
track\_xml.onLoad = function(success){  
if (success) CreateMenu(this);  
else trace(“Error loading XML file”);  
}  
track\_xml.load(“tracks.xml”);

var item\_spacing = 23;  
var item\_count = 0;

function CreateMenu(menu\_xml){  
var items = menu\_xml.firstChild.firstChild.childNodes;  
for (var i=0; i\<items.length; i++) {  
if (items\*.attributes.type == “track”) {  
var track = items\*.firstChild.childNodes;  
var item\_mc = menu\_mc.attachMovie(“main\_btn”,“main\_btn”+item\_cou nt, item\_count);  
item\_mc.\_y = (item\_count \* item\_spacing);  
item\_count++;  
item\_mc.\_x = 0

item\_mc.track\_txt.text = track;

}  
}  
}

[COLOR=black]item\_mc.[COLOR=#000080]main\_btn0[/COLOR].[COLOR=#0000ff]onPress[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]  
[COLOR=#0000ff]trace[/COLOR] COLOR=#000000[/COLOR]  
[COLOR=#000000]}[/COLOR][/COLOR]
