Search code examples
flashactionscript-3actionscriptflash-cs3

Create a map in flash and zoom into it


enter image description hereI've created a world map in flash and I want to code an ActionScript so that if I click on a country the map, it should zoom into it and show some information beside the country.

I dont know how to start it. A sample could be better.

Please let me know if you know any good step by step turial site.

Find the pic here for reference : ASIA

I have added the ASIA part which i have created. When i click on India, it should zoom into it.


Solution

  • Create an outermost container that is centred on the stage:

    var shell:MovieClip = new MovieClip();
    shell.x = stage.stageWidth / 2;
    shell.y = stage.stageHeight / 2;
    
    addChild(shell);
    

    Create an inner container and add this to the shell:

    var inner:MovieClip = new MovieClip();
    shell.addChild(inner);
    

    Place your map within the inner:

    inner.addChild(my_map);
    

    To zoom, scale the shell:

    shell.scaleX = shell.scaleY = 2.2;
    

    And to define what point you want to have centred on the stage (what you want to focus on), set the x and y of inner to be negative of the point. Like, say if Australia was at 300,220:

    inner.x = -300;
    inner.y = -220;