# Setting a global variable from within a function?

**URL:** <https://forum.kirupa.com/t/setting-a-global-variable-from-within-a-function/233445>\
**Category:** flash\
**Created:** [July 24, 2007, 3:15am UTC](https://forum.kirupa.com/t/setting-a-global-variable-from-within-a-function/233445 "2007-07-24T03:15:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Head\_In\_A\_Pan](https://avatars.discourse-cdn.com/v4/letter/h/c67d28/32.png) [@Head\_In\_A\_Pan](https://forum.kirupa.com/u/Head_In_A_Pan)\
**Post date:** [July 24, 2007, 3:15am UTC](https://forum.kirupa.com/t/setting-a-global-variable-from-within-a-function/233445/1 "2007-07-24T03:15:42Z")

</div>

Hello!

I thought the following was how I set a global variable from within a function, but I’m not getting a trace on it…

So how do I set a global variable from within a function?! 🙂

```auto

_global.myVariable = this;

btn_first.onRelease = function(){
_global.myVariable.property="First";
trace(myVariable);
}

btn_second.onRelease = function(){
_global.myVariable.property="Second";
trace(myVariable);
}

```
