# AS3 - duplicate variable definition?

**URL:** <https://forum.kirupa.com/t/as3-duplicate-variable-definition/196903>\
**Category:** flash\
**Created:** [August 11, 2006, 7:00pm UTC](https://forum.kirupa.com/t/as3-duplicate-variable-definition/196903 "2006-08-11T19:00:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ignitrix](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ignitrix/32/2664_2.png) [@ignitrix](https://forum.kirupa.com/u/ignitrix)\
**Post date:** [August 11, 2006, 7:00pm UTC](https://forum.kirupa.com/t/as3-duplicate-variable-definition/196903/1 "2006-08-11T19:00:14Z")

</div>

If I have the following AS3 code inside of a class:

```php
public function doStuff():void
{
   for (var i:uint = 0; i < myArray.length; i++)
    {
       // do stuff
    }

   for (var i:uint = 0; i < myArray.length; i++)
    {
       // do stuff
    }
}

```

I get a “Duplicate variable definition” compiler complaint. Obviously I could declare the _i_ variable once within the function call to avoid the issue, but I shouldn’t have to. The first _i_ should be out of scope before the second _for_ loop begins. Any ideas?

Thanks,  
~JC
