# Var Inside Function

**URL:** <https://forum.kirupa.com/t/var-inside-function/241877>\
**Category:** flash\
**Created:** [October 19, 2007, 1:36am UTC](https://forum.kirupa.com/t/var-inside-function/241877 "2007-10-19T01:36:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![outdoors](https://avatars.discourse-cdn.com/v4/letter/o/e56c9b/32.png) [@outdoors](https://forum.kirupa.com/u/outdoors)\
**Post date:** [October 19, 2007, 1:36am UTC](https://forum.kirupa.com/t/var-inside-function/241877/1 "2007-10-19T01:36:05Z")

</div>

Hi,

I know this has been asked before but no solid answer yet.

I want to declare a var inside a function and then access it from the outside. This does not work. I know i can do it with classes or declaring it from teh outside but for this project it would be to complex. So please, is there any way of declaring a var inside a function and get access to it from the outside.

Example:

init()  
function init () {  
var myVar=12345  
}

trace(myVar)  
//Result = 1120: Access of undefined property myVar.
