Mapping system - problems - please help

Hello,

I am currently working on a mapping system in Flash CS3 using AS3. All is going fairly well, however, I’m having a small problem with centering.

With the advice from other posters on this forum a few months ago, I nested my map into 3 main movieclips. There’s a “map_container” movieclip, which is the main movieclip. Then the actual “map_mc” which contain the actual map within. Then I have a “layers_mc”, which contains my mapping data (roads, poi, etc).

My zoom class increases the scale of the “map_container”. My movie class moves the x and y position of “map_mc”. My poi class adds points of interest to various points within “layers_mc”.

When the user clicks on the POI on the map, a box pops up with information related to the POI (kind of like google maps does it). However, sometimes when the POI box is large, or the POI is off to the side of the map, the user cannot see the POI information, until they move the map manually.

Basically, I need to center (move) the “map_mc” so that the POI will center to the stage. I’ve tried just about every math solution that I can think of, but I can’t get the POI to center.

Please note that my registration points for all movieclips are at Center.

Here are some of the solutions i’ve tried:
1.

map.x = (-POI.x);
map.y = (-POI.y);


var relXpos = (theXpos / map.width) * stageWidth;        // get the relative x position of the box
var relYpos = (theYpos / map.height) * stageHeight;   // get the relative y position of the box

var xCenter = (stageWidth /2) - relXpos;
var yCenter = (stageHeight /2) - relYpos;

var moveX = relXpos - xCenter;
var moveY = relYpos - yCenter;


var theXpos = infoBox.x + (infoBox.width / 2);
var theYpos = infoBox.y - (infoBox.height / 2);
 
var xpos = theXpos + (map.parent.width / 2);
var rel_x = (xpos / map.parent.width) * stageWidth;

Any help or ideas/suggestions with this would be appreciated.

Thank you.