I have a movie clip of all counties in the state of Montana (allcnt_mc). Within ***allcnt_mc ***there are individual movie clips specific to each county with name equal to the county’s name. When clicking on a county, I’d like to zoom to that county and center the stage on it. I’ve added event listeners to all counties through querying an xml table that has demographic info I am calling into dynamic text boxes. Here is the code I have thus far to load the xml and add the listeners to the county movie clips.
//load xml
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("cntydat.xml"));
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
createListeners();
}
//create listeners for all mc's and designate functions
function createListeners():void{
for(var i:uint=0;i<xmlData.row.NAME.length();i++){
var mc:MovieClip = MovieClip(allcnt_mc.getChildByName(xmlData.row.NAME*));
mc.ivar = i;
mc.addEventListener(MouseEvent.MOUSE_OVER,zoomin);
I’ve also specified a functions on CLICK and MOUSE_OUT called zoomin and zoomout.
I’d like zoom in to zoom to the extent of the county movie clip i’ve clicked on. To create the effect of zooming on the whole state, I’ll scaleX and scaleY the allcnt_mc.
Where I need help is making the extent of the zoom proportional to the dimensions of the child movie clip I’ve clicked on and centering the stage over the county I’ve called on. For an example of how I’ve been calling on the counties and changing their color on MOUSE_OVER, I’ve been using this function
function colchange(e:Event):void{
var ct:ColorTransform=e.currentTarget.transform.colorTransform;
ct.color=overColor;
e.currentTarget.transform.colorTransform=ct
}
To accomplish the effect I am going after, I imagine I’ll create a CLICK event that scales the X and Y of ***allcnt_mc***and make that proportional to e.currentTarget and also moves the whole allcnt_mc, centering it over the e.currentTarget. Another click would reverse the process, scaling allcnt_mc back to 1 and centering over allcnt_mc. I am just missing some action that would call on the geometry/coordinates of the e.currentTarget.
If anyone could help move me in the right direction, I’d really appreciate it.
Thanks so much in advance,
Josh