# myVar = x gives undefined :(

**URL:** <https://forum.kirupa.com/t/myvar-x-gives-undefined/217869>\
**Category:** flash\
**Created:** [March 2, 2007, 4:02pm UTC](https://forum.kirupa.com/t/myvar-x-gives-undefined/217869 "2007-03-02T16:02:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kingscooty](https://avatars.discourse-cdn.com/v4/letter/k/73ab20/32.png) [@kingscooty](https://forum.kirupa.com/u/kingscooty)\
**Post date:** [March 2, 2007, 4:02pm UTC](https://forum.kirupa.com/t/myvar-x-gives-undefined/217869/1 "2007-03-02T16:02:45Z")

</div>

This is the code i’ve got, basically checks finds the x,y position of number 2 in a multidimensional array. For some reason sprite.px = x and sprite.py = y give undefined messages when i trace them. What am i doing wrong?

[AS]  
for (var x = 0; x\<map[x].length; x++) {  
for (var y = 0; y\<map.length; y++) {  
if (map[y][x] == 2) {  
trace(x);  
trace(y);  
sprite.px = x;  
sprite.py = y;  
trace(sprite.px);  
trace(sprite.py);  
}  
}  
}  
[/AS]
