The following code centers the parent clip “mapcontainer.themap” on the state Georgia on load. However, when i try to scale mapcontainer.themap, it doesnt scale around Georgia’s center. How do i keep Georgia in the center when scaling?
//This sets the parent clip so it's centered on the child "georgia" clip on load
var yValue:Number = mapcontainer.themap.georgia.y;
var xValue:Number = mapcontainer.themap.georgia.x;
var xDiff:Number = mapcontainer.themap.width/2;
var yDiff:Number = mapcontainer.themap.height/2;
if (xDiff > stage.stageWidth/2 || yDiff > stage.stageHeight/2) {
xValue = -xValue;
yValue = -yValue;
}
mapcontainer.themap.x = xValue;
mapcontainer.themap.y = yValue;
//This line?
mapcontainer.themap.scaleX = mapcontainer.themap.scaleY = 2;
Here is a function derived from here
So for your scenario, you could do this: