# Incrementing variable problem

**URL:** <https://forum.kirupa.com/t/incrementing-variable-problem/112728>\
**Category:** Uncategorized\
**Created:** [June 10, 2004, 8:49pm UTC](https://forum.kirupa.com/t/incrementing-variable-problem/112728 "2004-06-10T20:49:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lacuna](https://avatars.discourse-cdn.com/v4/letter/l/edb3f5/32.png) [@Lacuna](https://forum.kirupa.com/u/Lacuna)\
**Post date:** [June 10, 2004, 8:49pm UTC](https://forum.kirupa.com/t/incrementing-variable-problem/112728/1 "2004-06-10T20:49:30Z")

</div>

Hey fellow Kirupians,

I have the following code and i need it to be able to use the line

```
_root.songPlay = this.song+(_root.songNum);

```

to change to \_root.songPlay = this.song1  
\_root.songPlay = this.song2  
\_root.songPlay = this.song3

and so on as the songNum changes variables.

However, it wont work properly, does anyone see how i can script that line to use whatever songNum is at the moment?

```php

_root.songNum = 1;
loadText = new LoadVars();
loadText.load("info.txt");
loadText.onLoad = function() {
	_root.songPlay = this.song+(_root.songNum);
	trace(songPlay);
	maxNum.text = this.maxNum;
	songName.text = _root.songPlay;
};

```

~ Lacuna aka Seretha B. :love:
