# A Challange! Varibles in if statement change from orginal automagicly?!

**URL:** <https://forum.kirupa.com/t/a-challange-varibles-in-if-statement-change-from-orginal-automagicly/135017>\
**Category:** Uncategorized\
**Created:** [January 23, 2005, 10:27pm UTC](https://forum.kirupa.com/t/a-challange-varibles-in-if-statement-change-from-orginal-automagicly/135017 "2005-01-23T22:27:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ckonkel](https://avatars.discourse-cdn.com/v4/letter/c/ed655f/32.png) [@ckonkel](https://forum.kirupa.com/u/ckonkel)\
**Post date:** [January 23, 2005, 10:27pm UTC](https://forum.kirupa.com/t/a-challange-varibles-in-if-statement-change-from-orginal-automagicly/135017/1 "2005-01-23T22:27:43Z")

</div>

Here is my problem:

I am having problems with the

getcoord = xycoordMap[x][y].split(":");  
xcoord = getcoord[0].toString();  
ycoord = getcoord[1].toString();  
xcoord0 = xcoord + “”;  
ycoord0 = ycoord + “”;

code… as you can see in the code I converted three times just to verify that I was working with strings. What happens if you run this script, the variables xcoord0 and ycoord0 magicly change in value when they are used in the IF statement (see the traces). What is going on?? what am I doing worng?? Is there an issue with my 2d Array? Please help with example code or a good explaination.

-CK

Here is the code:

locationMap = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 8, 1, 8, 1, 8, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 8, 1, 8, 1, 8, 1, 8, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 8, 1, 8, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 8, 1, 8, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 8, 1, 8, 1, 8, 1, 0, 1, 8, 1, 0, 1, 0], [0, 1, 0, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1], [1, 0, 1, 8, 1, 8, 1, 8, 1, 8, 1, 0, 1, 0, 1, 0], [0, 1, 8, 1, 0, 1, 8, 1, 8, 1, 8, 1, 0, 1, 8, 1], [1, 0, 1, 8, 1, 8, 1, 8, 1, 8, 1, 0, 1, 0, 1, 0], [0, 1, 8, 1, 0, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1], [1, 8, 1, 0, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 0], [0, 1, 0, 1, 0, 1, 8, 1, 8, 1, 8, 1, 8, 1, 0, 1], [1, 8, 1, 0, 1, 8, 1, 8, 1, 8, 1, 8, 1, 0, 1, 0], [0, 1, 0, 1, 8, 1, 8, 1, 8, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 8, 1, 8, 1, 0, 1, 8, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 8, 1, 0, 1, 0, 1, 8, 1, 0, 1, 0, 1], [1, 0, 1, 8, 1, 0, 1, 0, 1, 8, 1, 8, 1, 8, 1, 0], [0, 1, 0, 1, 8, 1, 0, 1, 0, 1, 8, 1, 8, 1, 0, 1], [1, 0, 1, 8, 1, 8, 1, 0, 1, 0, 1, 8, 1, 8, 1, 0], [0, 1, 0, 1, 8, 1, 8, 1, 0, 1, 0, 1, 8, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]];  
shiftdown = 0;  
shiftright = 0;  
xycoordMap = new Array(25);  
for (var x = 0; x\<25; ++x) {  
xycoordMap[x] = new Array(16);  
shiftright = 0;  
shiftdown = shiftdown+10;  
for (var y = 0; y\<16; ++y) {  
num = (x/2);  
floored = Math.floor(num);  
//if even row  
if ((floored-num) == 0) {  
if (flop == 1) {  
xycoordMap[x][y] = “”+(shiftright+10)+":"+(shiftdown+0)+"";  
flop = 0;  
} else {  
xycoordMap[x][y] = “_";  
flop = 1;  
}  
//trace(“x:”+x+" is even"+" y="+y);  
//trace(“xycoordMap=”+xycoordMap[x][y]);  
} else {  
// if odd row  
if (flip == 1) {  
xycoordMap[x][y] = "_”;  
flip = 0;  
} else {  
xycoordMap[x][y] = “”+(shiftright+10)+":"+(shiftdown+0)+"";  
flip = 1;  
}  
//trace(“x:”+x+" is odd"+" y="+y);  
//trace(“xycoordMap=”+xycoordMap[x][y]);  
}  
shiftright = shiftright+15;  
}  
}  
for (x=0; x\<25; ++x) {  
trace(x+": ------------------------------------");  
for (y=0; y\<16; ++y) {  
//trace(“locationmap:”+locationMap[x][y]);  
locationgrid = locationMap[x][y];  
getcoord = xycoordMap[x][y].split(":");  
xcoord = getcoord[0].toString();  
ycoord = getcoord[1].toString();  
xcoord0 = xcoord + “”;  
ycoord0 = ycoord + “”;

```
    trace("xcoord0 "+xcoord0);
    trace("ycoord0 "+ycoord0);
    trace("locationgrid = "+locationgrid);
    if (locationgrid == 8) {
        tilename = "t_"+x+"_"+y;
        trace("tilename"+tilename);
        trace(x+" - xcoord0 "+xcoord0);
        trace(y+" - ycoord0 "+ycoord0);
        //this.attachMovie("tile",tilename, this.getNextHighestDepth());
        //this.tilename._x = temp3[0];
        //this.tilename._y = temp3[1];
    }
}

```

}
