# Output values for buttons in loop

**URL:** <https://forum.kirupa.com/t/output-values-for-buttons-in-loop/279323>\
**Category:** flash\
**Created:** [January 13, 2009, 1:45pm UTC](https://forum.kirupa.com/t/output-values-for-buttons-in-loop/279323 "2009-01-13T13:45:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![2\_C](https://avatars.discourse-cdn.com/v4/letter/2/9dc877/32.png) [@2\_C](https://forum.kirupa.com/u/2_C)\
**Post date:** [January 13, 2009, 1:45pm UTC](https://forum.kirupa.com/t/output-values-for-buttons-in-loop/279323/1 "2009-01-13T13:45:08Z")

</div>

I have this little loop that creates buttons.  
My aim is to change value of variable ‘thevalue’ on everytime button is pressed, first button should give value 0, second 1, third 2 and so on.

```auto
for (jo=0; jo<xmlData.firstChild.childNodes.length; jo++) {
            value1= xmlData.firstChild.childNodes[jo].attributes.value;
            _root.attachMovie("button", jo, (1000-jo), {_x:20, _y:20+(jo*20)});
            _root[jo].onPress = function () {
                thevalue=jo;
                _root.actions.Scramble();

            }
}

```

So help me God 'cos im running slo.
