# AS3 Var Scope

**URL:** <https://forum.kirupa.com/t/as3-var-scope/318533>\
**Category:** flash\
**Created:** [January 23, 2011, 5:19am UTC](https://forum.kirupa.com/t/as3-var-scope/318533 "2011-01-23T05:19:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![megshea](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@megshea](https://forum.kirupa.com/u/megshea)\
**Post date:** [January 23, 2011, 5:19am UTC](https://forum.kirupa.com/t/as3-var-scope/318533/1 "2011-01-23T05:19:55Z")

</div>

Hey Friends,

If I set a var outside a function, the code in that function would still see it, right? Should code like this work? I am trying to get code set in a function to be visible globally…

```
var myArray:Array = new Array();

function myArray() {
   myArray[0] = "hey dude";
}

trace(myArray[0]);
```
