Scary change of var values

[Edit] Found out that another function was running concurrently and changing x’s value. :block: <- block head = me

I have two functions, flatline2() and lines(). In flatline2() I’ve set x=0, but when I call lines() the var x as well as other vars are incremented by one.

**flatline2**=function(leninter){
 
 _global.x++;
 pen2.lineTo(_global.x*magnify,0  *magnify);
 
 if (intx==leninter){
  clearInterval(flat2);
  complex2=setInterval(lines2,drawspeed);
 }
 
 if (_global.x==endofscreen){
  clearInterval(flat2);
  arraystart=count;
  pen2.swapDepths(pen1);
 
  [COLOR=red]**_global.x=0;**
[/COLOR]
  pen1.clear();  
   pen1.lineStyle(2, 0x00ee00, 100);
  pen1.moveTo(_global.x*magnify,ekgarr[arraystart]*magnify); 
 
   **[COLOR=red]trace("here x:"+_global.x+" count:"+count+"arraystart:"+arraystart);   [/COLOR]**
[COLOR=red]
**pattime=setInterval([COLOR=black]lines[/COLOR],drawspeed);**[/COLOR]
 
 }
 
 intx++;
 
} 
**lines**=function(){
   **[COLOR=red]trace("x"+_global.x+"count"+count);[/COLOR]**
.
.
.
etc.

Trace output looks like this:

here x:0 count:0arraystart:0
x1count1

Any clue to what’s going on?