# Assign value to variables using a "for loop"

**URL:** <https://forum.kirupa.com/t/assign-value-to-variables-using-a-for-loop/315780>\
**Category:** Uncategorized\
**Created:** [November 3, 2010, 8:43pm UTC](https://forum.kirupa.com/t/assign-value-to-variables-using-a-for-loop/315780 "2010-11-03T20:43:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThreeDollarBill](https://avatars.discourse-cdn.com/v4/letter/t/7ea924/32.png) [@ThreeDollarBill](https://forum.kirupa.com/u/ThreeDollarBill)\
**Post date:** [November 3, 2010, 8:43pm UTC](https://forum.kirupa.com/t/assign-value-to-variables-using-a-for-loop/315780/1 "2010-11-03T20:43:33Z")

</div>

is it possible to assign a value to variables using a for loop?

without using a “for loop”, this is how it would usually be done…

```auto
var stringOne:String;
var stringTwo:String;
var stringThree:String;
            
stringOne = "first..";
stringTwo = "second...";
stringThree = "third...";
            
trace(stringOne, stringTwo, stringThree); // traces "first.. second... third..."

```

in an attempt to assign a value to the variables using a “for loop”, this is how the code could be written…

```auto
var stringOne:String;
var stringTwo:String;
var stringThree:String;
            
var stringArray:Array = [stringOne, stringTwo, stringThree];
var stringDefs:Array = ["first..", "second...", "third..."];
            
for (var i:int = 0; i < stringArray.length; i++)
{
    stringArray* = stringDefs*;
}
            
trace(stringOne, stringTwo, stringThree); // traces "null null null"

```

doesn’t work…

any solutions?  
i need to be able to assign a value to the variables automatically… otherwise i’m going to have to do it the manual way…
