# Array Loop - result plus "instance\_name.text"?

**URL:** https://forum.kirupa.com/t/array-loop-result-plus-instance-name-text/310466
**Category:** flash
**Created:** [June 10, 2010, 7:08pm UTC](https://forum.kirupa.com/t/array-loop-result-plus-instance-name-text/310466 "2010-06-10T19:08:08Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Monte323](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@Monte323](https://forum.kirupa.com/u/Monte323)
#### Post date: [June 10, 2010, 7:08pm UTC](https://forum.kirupa.com/t/array-loop-result-plus-instance-name-text/310466/1 "2010-06-10T19:08:08Z")

</div>

Hello all - I’m sure there is a very simple solution to what I’m trying to do, I’m just not getting it. I have a bunch of input boxes on my project stage, they all will be restricted to containing numbers. What I am trying to do is write a loop that pulls out the number value for each one and assigns it to a global variable to be pulled later in the project.

Here is the code I am using:

function myFunction( event:Event ):void {  
var instanceArray:Array = new Array(“instance1”, “instance2”);  
var globalVariableArray:Array = new Array(“global1”, “global2”);

var i:int;  
for (i = 0; i \< (instanceArray.length); i++) {  
var sValue:String = String(String(instanceArray\*)+.text);  
var nValue:Number = Number(sValue);  
MyGlobal.String(globalVariableArray\*) = nValue;  
}

}

I can trace the array fine, the problem that I am having is that I am unable to put together the value into the strings so that this code ends up outputting:

Loop 1 --\>  
var sValue:String = String(instance1.text);  
var nValue:Number = Number(sValue);  
MyGlobal.global1 = nValue;  
Loop 2 --\>  
var sValue:String = String(instance2.text);  
var nValue:Number = Number(sValue);  
MyGlobal.global2 = nValue;

I appreciate any advice you may have!

Thank you,  
Keith
