Creating an Editable Grid

I’m having problems creating a grid that will change individual movieclips’ frame when rolled over when the mouse is down. My script seems to be acting erratically, when I push buttons, all of the mcs change even though the code to change them is onRollOver.

An example of what I am talking about is here:
www.barbdwyer.com/games/maze/maze.swf
Click on the “Create Your Own Map” button in the bottom left.
Then you should be able to use the buttons in the bottom right to select the new color/value of the grid items.

Here is the code I am using to do this:


_root.mouseIsDown = 0;
wallSel.gotoAndStop("wall");
pathSel.gotoAndStop("path");
startSel.gotoAndStop("start");
goalSel.gotoAndStop("goal");
createEditableMaze();
stop();
function createEditableMaze() {
dimensions = 400;
 
//0 Is a Wall
//1 Is a Travelable Place
//2 Is the starting Point
//3 Is the Goal
 
numRows = 30;
numColumns = 30;
k=0;
 
individualHeight = dimensions / numRows;
individualWidth = dimensions / numColumns;
 
createEmptyMovieClip("theMaze", -11);
theMaze._x = 4.5;
theMaze._y = 4;
theMaze.i = 0;
 
_root.theGoal = new Array();
_root.theGoal[0] = -1;
_root.theGoal[1] = -1;
 
_root.startingPosition = new Array();
_root.startingPosition[0] = -1;
_root.startingPosition[1] = -1;
 
_root.theMap = new Array();
_root.changeToFrame = "path";
_root.changeToNum = 1;
 
for(i=0; i<numRows; i++) {
theMap* = new Array();
for(j=0; j<numColumns; j++) {
theMaze.attachMovie("tile", "tileR"+i+"C"+j, theMaze.i);
theMaze["tileR"+i+"C"+j].gotoAndStop("wall");
theMaze["tileR"+i+"C"+j]._height = individualHeight;
theMaze["tileR"+i+"C"+j]._width = individualWidth;
theMaze["tileR"+i+"C"+j]._y = individualHeight * i;
theMaze["tileR"+i+"C"+j]._x = individualWidth * j;
 
theMaze["tileR"+i+"C"+j].row = i;
theMaze["tileR"+i+"C"+j].column = j;
 
_root.theMap*[j] = 0;
 
theMaze["tileR"+i+"C"+j].onRollOver = function() {
if(_root.mouseIsDown == 1) {
if(_root.changeToNum == 2) {
if(startingPosition[0] != -1) {
_root.theMap[startingPosition[0]][startingPosition[1]] = 1;
_parent["tileR"+_root.startingPosition[0]+"C"+_root.startingPosition[1]].gotoAndStop("path");
}
_root.startingPosition[0] = this.column;
_root.startingPosition[1] = this.row;
} else if(_root.changeToNum == 3) {
_root.theMap[theGoal[0]][theGoal[1]] = 1;
_parent["tileR"+_root.theGoal[0]+"C"+_root.theGoal[1]].gotoAndStop("path");
_root.theGoal[0] = this.column;
_root.theGoal[1] = this.row;
}
_root.theMap[this.row][this.column] = _root.changeToNum;
this.gotoAndStop(_root.changeToFrame);
}
}
theMaze["tileR"+i+"C"+j].onMouseDown = function() {
if(_root.changeToNum == 2) {
if(startingPosition[0] != -1) {
_root.theMap[startingPosition[0]][startingPosition[1]] = 1;
_parent["tileR"+_root.startingPosition[0]+"C"+_root.startingPosition[1]].gotoAndStop("path");
}
_root.startingPosition[0] = this.column;
_root.startingPosition[1] = this.row;
} else if(_root.changeToNum == 3) {
_root.theMap[theGoal[0]][theGoal[1]] = 1;
_parent["tileR"+_root.theGoal[0]+"C"+_root.theGoal[1]].gotoAndStop("path");
_root.theGoal[0] = this.column;
_root.theGoal[1] = this.row;
}
_root.theMap[this.row][this.column] = _root.changeToNum;
this.gotoAndStop(_root.changeToFrame);
}
 
theMaze.i++;
}
}
border.swapDepths(theMaze);
}
wallSel.onRelease = function() {
_root.changeToNum = 0;
_root.changeToFrame = "wall";
}
pathSel.onRelease = function() {
_root.changeToNum = 1;
_root.changeToFrame = "path";
}
startSel.onRelease = function() {
_root.changeToNum = 2;
_root.changeToFrame = "start";
}
goalSel.onRelease = function() {
_root.changeToNum = 3;
_root.changeToFrame = "goal";
}
getMouse = new Object();
Mouse.addListener(getMouse);
getMouse.onMouseDown = function() {
_root.mouseIsDown = 1;
}
getMouse.onMouseUp = function() {
_root.mouseIsDown = 0;
}

It is on frame two of the movie.

Thanks in advance for any help you can provide =)