# Global variable problem

**URL:** https://forum.kirupa.com/t/global-variable-problem/278467
**Category:** Uncategorized
**Created:** [December 30, 2008, 5:48pm UTC](https://forum.kirupa.com/t/global-variable-problem/278467 "2008-12-30T17:48:16Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Blackcat](https://avatars.discourse-cdn.com/v4/letter/b/c37758/32.png) [@Blackcat](https://forum.kirupa.com/u/Blackcat)
#### Post date: [December 30, 2008, 5:48pm UTC](https://forum.kirupa.com/t/global-variable-problem/278467/1 "2008-12-30T17:48:16Z")

</div>

hi  
i have a problem with a global variable.  
first of all i should explain you my flash file:  
it’s made like the rpg tutorial here… so i’m generating my maps and a status menu on frame 6:

```auto
 
...
MapMaker(map1);
MapMaker2(map2);
placeItems(itemMap1);
MapMaker3(map3);
MapMaker4(map4);
  _root.attachMovie("Status", "status", _root.getNextHighestDepth());

```

at the first frame i declare my two variables:  
\_global.schritte=0; // steps my pc walked  
\_global.attack=false; //monster attack

at the status movieclip (see above) i used this one to check the steps:

```auto
  
   if (_global.schritte > 200) {
   _root.attachMovie("Battle", "a_battle", _root.getNextHighestDepth()-2);
   _global.attack = true;
   _global.schritte=0;
 } 

```

my char walks that way:

```auto
 if (Key.isDown(Key.UP)) { 
 play();
  if (checkCoords(_parent._x, _parent._y - walkSpeed,0)){
 
 _parent._y-= walkSpeed;
 _root.items.guy_mc.char._y-= walkSpeed;
  _global.schritte+=random(walkSpeed);
    trace(_global.schritte); 
 }}

```

i used the trace function to watch the steps but the went higher than 200 and nothing happend :stare:

i used a similar method with the menu and it works :

```auto
on (press) {
 if (_global.menu == false) {
   _root.attachMovie("Menu", "a_menu", _root.getNextHighestDepth()-2);
   _global.menu = true;
 } else {
 _root.a_menu.removeMovieClip();
 _global.menu = false;
 _root.gotoAndPlay(6);
 }
}

```

you can test it here:  
[http://www.animeschatten.net/game/flash/map.swf](http://www.animeschatten.net/game/flash/map.swf)

**[SIZE=4]Please help me!![/SIZE]**
