# Dynamicaly creating/acessing variables

**URL:** <https://forum.kirupa.com/t/dynamicaly-creating-acessing-variables/315041>\
**Category:** Uncategorized\
**Created:** [October 15, 2010, 7:07pm UTC](https://forum.kirupa.com/t/dynamicaly-creating-acessing-variables/315041 "2010-10-15T19:07:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vfistri1](https://avatars.discourse-cdn.com/v4/letter/v/d2c977/32.png) [@vfistri1](https://forum.kirupa.com/u/vfistri1)\
**Post date:** [October 15, 2010, 7:07pm UTC](https://forum.kirupa.com/t/dynamicaly-creating-acessing-variables/315041/1 "2010-10-15T19:07:29Z")

</div>

is it possible to dynamically create variables in actionscript?  
for example lets say i have some kind of loop and for each itteration of loop i want new variable to be created, or acssed if creatin is not possible. ( tbh i don’t need to create them dynamically there is more simple sollution of my problem in real project, am just wandering is it possible )

this is what i have tried for creating but it doesnt work:  
(it also doesnt work if i add [“number”+i] ) instead of (“number”+i)

```php

for(var i:int=0; i<9; i++){
    var ("number"+i):int = i ;
    trace(("number"+i));
}

```

this is for acessing also doesnt work:

```php

var number1:int = 0;
var number2:int =29;
var number4:int = 36;
.....
for(var i:int=0; i<9; i++){
    trace(("number"+i));
}

```

the best i could thought for acessing is filling them in array and acessing it like that… code works but i am actually trying to make it work without array

```php

var var1:int= 0;
var var2:int= 290;
var var3:int= 59;
var array:Array = [var1,var2,var3]
for(var i:int=0; i<9; i++){
    trace(array*);
}

```
