# Please help!

**URL:** <https://forum.kirupa.com/t/please-help/261234>\
**Category:** Uncategorized\
**Created:** [May 24, 2008, 5:47pm UTC](https://forum.kirupa.com/t/please-help/261234 "2008-05-24T17:47:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stupidsaint](https://avatars.discourse-cdn.com/v4/letter/s/258eb7/32.png) [@stupidsaint](https://forum.kirupa.com/u/stupidsaint)\
**Post date:** [May 24, 2008, 5:47pm UTC](https://forum.kirupa.com/t/please-help/261234/1 "2008-05-24T17:47:20Z")

</div>

i need some help. i have some code but its stupidly long:

```auto

if(_global.ticker == 1){
    _global.info = text1
}
if(_global.ticker == 2){
    _global.info = text2
}
if(_global.ticker == 3){
    _global.info = text3
}
if(_global.ticker == 4){
    _global.info = text4
}
//ect...

```

Please help and could you explain the code too, thanks

Stupid Saint

---

<div class="post-metadata">

**Author:** ![Michael\_Chen](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@Michael\_Chen](https://forum.kirupa.com/u/Michael_Chen)\
**Post date:** [May 24, 2008, 8:06pm UTC](https://forum.kirupa.com/t/please-help/261234/2 "2008-05-24T20:06:09Z")

</div>

Try this…

```auto

_global.ticker = 2;
_global.info = "nothing";

// Assuming that text1 ~ text 4 are setup like so...
var text1:String = "text1 String";
var text2:String = "text2 String";
var text3:String = "text3 String";
var text4:String = "text4 String";

// Number of text strings.
var numOfText:Number = 4;

// Loops through from 1 to numOfText (4).
// For more info search for "for statement" in the help doc.
for(var a:Number = 1; a <= numOfText; a++) {

	if(_global.ticker == a){
		// info gets assigned the value of variable name "text" + a.
    	        _global.info = this["text" + a];
		
		// Check that the right value was assigned.
		trace(_global.info);
	}
}

```

Note: this can also be done with arrays.
