# AS3: Arrays....am i doing it "noob-style"

**URL:** https://forum.kirupa.com/t/as3-arrays-am-i-doing-it-noob-style/280042
**Category:** flash
**Created:** [January 22, 2009, 2:14am UTC](https://forum.kirupa.com/t/as3-arrays-am-i-doing-it-noob-style/280042 "2009-01-22T02:14:07Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![crucifix](https://avatars.discourse-cdn.com/v4/letter/c/bc79bd/32.png) [@crucifix](https://forum.kirupa.com/u/crucifix)
#### Post date: [January 22, 2009, 2:14am UTC](https://forum.kirupa.com/t/as3-arrays-am-i-doing-it-noob-style/280042/1 "2009-01-22T02:14:07Z")

</div>

I want to make a mc based on a variable tht i get from the mousewheel function.

```auto

currGun = gunList[gunOper]
removeChild(iGun);
if(currGun=="SCAR_GUN_mc"){
     iGun = new SCAR_GUN_mc;
} else if (currGun=="SPAS12_GUN_mc"){
    iGun = new SPAS12_GUN_mc;
} else if (currGun=="BARRET_GUN_mc"){
    iGun = new BARRET_GUN_mc;
}
addChild(iGun);

```

So what im doing here is removing a mc and making another one based on a variable but this looks like a very slow and ineffetive way of doing this. I was hoping the i could just say something like iGun = new currGun but this doesnt work does anyone know of a more efficant way of doing this?  
Thanks kirupians:thumb:
