# Recording mouse positions in multidimensional array

**URL:** <https://forum.kirupa.com/t/recording-mouse-positions-in-multidimensional-array/87130>\
**Category:** Uncategorized\
**Created:** [April 18, 2005, 6:34pm UTC](https://forum.kirupa.com/t/recording-mouse-positions-in-multidimensional-array/87130 "2005-04-18T18:34:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fishbellyrust](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/fishbellyrust/32/784_2.png) [@fishbellyrust](https://forum.kirupa.com/u/fishbellyrust)\
**Post date:** [April 18, 2005, 6:34pm UTC](https://forum.kirupa.com/t/recording-mouse-positions-in-multidimensional-array/87130/1 "2005-04-18T18:34:07Z")

</div>

my intention:

creating a sketchpad that records mouse movements so the drawing can be played back.

problem:

\_xmouse and \_ymouse are not being saved in the array. i get an ‘undefined’ error when trying to read a position that should exist somewhere in the array.

code:

history = new Array();  
history[0] = new Array();  
history[0][0] = new Array();  
history[0][0][0] = new Array();  
var i = 0;  
var j = 0;  
\_root.createEmptyMovieClip(“line”, 1);  
\_root.onMouseDown = function() {

line.moveTo(\_xmouse, \_ymouse);  
line.lineStyle(1, 0x000000, 100);  
this.onMouseMove = function() {  
line.lineTo(\_xmouse, \_ymouse);  
updateAfterEvent();  
history\*[j][0] = \_xmouse;  
history\*[j][1] = \_ymouse;  
j += 1;  
};  
i += 1;  
j = 0;  
};  
\_root.onMouseUp = function() {  
this.onMouseMove = null;  
};  
this.button.onPress = function() {  
line.clear();  
for (a=0; history[a][0][0] != null; a++) {  
line.moveTo(history[a][0][0], history[a][0][1]);  
for (b=1; history[a]**[0] != null; b++) {  
line.lineTo(history[a]**[0], history[a]\*\*[1]);  
updateAfterEvent();  
}  
}  
};
