1

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.

Chandra Eskay
  • 2,163
  • 9
  • 38
  • 58

2 Answers2

1

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;
Marty
  • 39,033
  • 19
  • 93
  • 162
  • Thanks, but where the code should be added. I created a new layer and added the code to it but didnt work out. – Chandra Eskay May 06 '11 at 07:04
  • Ok, replace **my_map** with **new Map()**. Then right click your map image in the library, select **export for actionscript** and then type **Map** into the class name field. Hit OK. – Marty May 06 '11 at 07:07
  • Do you know any tutorial site which can teach me from the beginning about flash scripting. Its better i will start from beginning. – Chandra Eskay May 06 '11 at 07:12
0

Clicking on a country to zoom into it is not so difficult, whether your country is a movie clip or you use some form of button overlay, you will eventually trigger a function

1/ that will tween into your map according to the event target/event target coordinates. 2/ open up a window showing the country's info Each country could be a class with a set of properties. Clicking on a country will basically pull out the info from the selected object to be displayed in the window

You seem to have handled the difficult part already , namely the design of the map itself.

PatrickS
  • 9,539
  • 2
  • 27
  • 31
  • Ya i know only the design part of Flash and so im finding difficulty in using ActionScript. May be some sample code wil be useful – Chandra Eskay May 06 '11 at 06:26