# Global scope gotcha - please help

**URL:** https://forum.kirupa.com/t/global-scope-gotcha-please-help/254620
**Category:** flash
**Created:** [March 13, 2008, 4:47pm UTC](https://forum.kirupa.com/t/global-scope-gotcha-please-help/254620 "2008-03-13T16:47:16Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Quarky](https://avatars.discourse-cdn.com/v4/letter/q/ba8739/32.png) [@Quarky](https://forum.kirupa.com/u/Quarky)
#### Post date: [March 13, 2008, 4:47pm UTC](https://forum.kirupa.com/t/global-scope-gotcha-please-help/254620/1 "2008-03-13T16:47:16Z")

</div>

Hi, I’m trying to set a global var within a LoadVars function and have it keep that value globally. In the following example, I define logStatus as a global variable and set it to “banana”, then within a function I set it to “orange”, then later outside the function its value is banana again. Why isn’t the global working here?

\_global.logStatus = “banana”;

var getUser\_lv:LoadVars = new LoadVars();  
getUser\_lv.load(“mypath.php”);

getUser\_lv.onLoad = function(success:Boolean){  
if(success){  
logStatus = “orange”;  
trace("logStatus in function is: "+logStatus);

```
 }else{
      logStatus = "apple";
      trace("logStatus in function is: "+logStatus);
 }

```

}

trace("logStatus after function is: "+logStatus);

The above example gives the following trace output:  
logStatus after function is: banana  
logStatus in function is: orange

You help would be appreciated.

Thanks  
Quarky
