# Function problem

**URL:** https://forum.kirupa.com/t/function-problem/331712
**Category:** Uncategorized
**Created:** [October 2, 2013, 5:11pm UTC](https://forum.kirupa.com/t/function-problem/331712 "2013-10-02T17:11:29Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![BindleStick](https://avatars.discourse-cdn.com/v4/letter/b/8491ac/32.png) [@BindleStick](https://forum.kirupa.com/u/BindleStick)
#### Post date: [October 2, 2013, 5:11pm UTC](https://forum.kirupa.com/t/function-problem/331712/1 "2013-10-02T17:11:29Z")

</div>

Is there a way to update a function?  
My Main function declares a var, but when the var changes on another function, it stays the same in the Main function. I guess it’s because the function is called once, right?

example:

```auto
public function Main()
{
level = 1;
addEventListener.(TimerEvent.TIMER, timerGame);
}

```

```auto
function timerGame(event:TimerEvent)
{
if (somethingHappens)
{
level = 2;
trace("NEXT LEVEL!");
}
}

```

The code is just a simple example of the problem I’m having.  
It works to a point that it traces level equaling 2, but the Main function is the one that creates the level. It still thinks level = 1 when “something happens.”
