Array-based Isometric Map Problems

Hi everyone,
this is my first post on a forum ever - I’ve been struggling with an isometric grid and decided it was about time I asked some knowledgeable people such as yourselves!
Basically I’ve got a map of tiles detailed in an array, which is then placed on the screen. This bit works fine, but when I try to place a movieclip on a tile (to see which one the mouse cursor is over), none of the tiles with an x/z value of 0 are registered by the engine. Here’s all the lovely code:

var map:Array = new Array();
map[0] = [1, 1, 1, 1, 1, 1];
map[1] = [1, 1, 1, 1, 1, 1];
map[2] = [1, 1, 1, 1, 1, 1];
map[3] = [1, 1, 1, 1, 1, 1];
map[4] = [1, 1, 1, 1, 1, 1];
map[5] = [1, 1, 1, 1, 1, 1];

var row:Number = 0;
var col:Number = 0;
var maxx:Number = _root.map.length;
var maxz:Number = _root.map[row].length;
var iso:Isometric = new Isometric(maxx, maxz);
trace (_root.map.length);
trace (“maxx=”+maxx);
trace (“maxz=”+maxz);

function buildWorld(maxx, maxz) {
world = new Object();
//maxx and maxz are world dimensions:
world.maxx = maxx;
world.maxz = maxz;
world.cellWidth = 29;
//length in x direction:
world.width = maxxworld.cellWidth;
trace (“world.width=”+world.width);
//length in z direction:
world.length = -maxz
world.cellWidth;
trace (“world.length=”+world.length);
world.path = this.floor;
var path:MovieClip = world.path;
buildFloor(path);
}
function buildFloor(path) {
path.tile._visible = false;
var y:Number = 0;
for (row = 0; row<_root.map.length; row++) {
for (col= 0; col<_root.map[row].length; col++) {

        var depth:Number = iso.calculateDepth(row, y, col);
        var name:String = "tile"+row+"_"+col;
        trace ("tile name="+name);
        trace ("tile depth="+depth);
        path.attachMovie(_root.map[row][col], name, depth);
        var clip:MovieClip = path[name];
        _root.map[row][col] = {x:row, y:y, z:col, depth:depth, clip:clip};
        var x:Number = (row-1)*world.cellWidth;
        var z:Number = -(col-1)*world.cellWidth;
        temp = iso.mapToScreen(x, y, z);
        clip._x = temp[0];
        clip._y = temp[1];
    }
}

}
function worldClicked(xm, ym) {
//this takes mouse coords and changes them to isoworld:
var temp = iso.mapToIsoWorld(xm, ym);
var xm:Number = temp[0];
var zm:Number = temp[1];
//checks to see if converted mouse coords are within the world:
if (xm>=0 && xm<=world.width && zm>=world.length && zm<=0) {
var x:Number = _xmouse;
itch = xm;
var z:Number = _ymouse;
scratch = zm;

    //mapToScreen then turns Iso coords back to Flash coords:
    var temp:Array = iso.mapToScreen(xm, 0, zm);
    var x:Number = xm;
    var z:Number = Math.abs(zm);
    var x_tile:Number = Math.ceil(x/world.cellWidth);
    var z_tile:Number = Math.ceil(z/world.cellWidth);
    hi = x_tile;
    yo = z_tile;
    //x seems to be working!
    //floor.character._x = (x_tile-z_tile)*world.cellWidth;
    floor.character._x = _root.map[x_tile][z_tile].clip._x;
    floor.character._y = _root.map[x_tile][z_tile].clip._y;
    //floor.character._y = (x_tile+z_tile)*world.cellWidth/2;
    sibx = floor.character._x;
    seby = floor.character._y;
    //this makes sure that the character is always on top of the file:
    var depth:Number = _root.map[x_tile][z_tile].depth+1;
    floor.character.swapDepths(depth);
}

}
buildWorld(maxx, maxz);
_root.onEnterFrame = function() {
worldClicked(floor._xmouse, floor._ymouse);
};
the problem seems to lie in checking if the mouse is within the iso world, because if I get rid of it , the x axis suddenly works fine (althought z axis is still skewed).
The code is based on an excellent book chapter from Flash MX 2004 Game Design Demystified.

I’m fairly new to Flash so there’s probably some obvious error that I’ve missed, but I’d really appreciate some feedback on this problem, especially if anyone owns the above book and has tried to do this as well.

Thanks