Zoom et Déplacement sur une carte.

 

The purpose is to display a map, then to move on it. Clicking a point allows to center the map on that point. Hit the '+' or '-' keys allow to zoom in/out.
This example 'll use pretty simple scripts. The map is inside the movie. Of course, it'd be better to load it as an external image to minimize the size of the swf file.
I suppose you know well how to create objects, thus I will not insist on.

⇒ animation ⇐

At first, Download the map.

Creating Object

1 - Set up width 360, height 270 and a background color #000066.
Frame Rate doesn't matter.

2 - Now create a rectangle (color #FFFF99), namedMask with a border thickness 1 , color #000000.
You'd yield :

Rectangle    Transform

This is the mask for the map.

3 - Import inside movie the image france.jpg
Named it themap. You'd yield :

image    Transform

4 - While maintaining the Shift key down, select the 2 previous objects.
Convert to Sprite, namedmap
Toggle Use bottom object as mask. You'd yield :

Sprite    Transform

5 -Now create a rectangle, (color #FFCC00), then modify it in triangle with tool reshape
You 'd yield bouton droit This is the right button.

Shape    Transform

6 - Then create a rectangle, (color #FFCC00), then modify it in triangle with tool reshape
You 'd yieldbouton gauche This is the left button.

Shape

7 - Then create a rectangle, (color #FFCC00), then modify it in triangle with tool reshape You 'd yield bouton bas This is the lower button..

Shape

8 - Then create a rectangle, (color #FFCC00), then modify it in triangle with tool reshape You'd yield : bouton haut This is the higher button.

Shape

9 - Now you gonna create a reticule. First, a rectangle border
You'd yield :

Rectangle    Transform

10 - Then, a vertical line lineV. You'd yield :

ligne    Transform

11 - Then, an horizontal line lineH. You'd yield :

ligne    Transform

12 - While maintaining the Shift key down, select the 3 previous objects.
Group them ( Menu Modify / Group / Group as Group )
Then convert that group to button, named boutonselect (target toggled)
Then convert that button to Sprite, named lens

Transform

13 - Now create text Reset, color #FFFF00. Convert it to button, named zoomout You'd yield :

texte    Transform

Outline 'd look like

Transform

SwishMax Scripts

Here is script for Scene_1

Here is script for zoomout. This button is used to get back to scale 100%, and previous position.
To zoom it : key '+'. To zoom out : key '-'.

Here is script for lens. The reticule gets alpha 0 when out of mask.

Here is script for topbutton

Here is script for bottombutton

Here is script for leftbutton

Here is script for rightbutton

Et voilà, that's it. Of course, this example is pretty simple. It's up to you to improve it.

 


Si vous aimez le site

 

Select a language if you need :


Page chargée en 0.004 sec.

Dernière Modification : Mer 25 Janvier 2017 8:56
Copyright © 1999-2017 Jean-Paul Molina Tous droits réservés.

to Google