China Naming Network - Ziwei Dou Shu - How does flash realize the Hawkeye function of the map?

How does flash realize the Hawkeye function of the map?

How does flash realize the Hawkeye function of the map?

Are you talking about a magnifying glass? If so, use the following code:

1. Import pictures. And based on this picture, a MovieClip is established and named "pic".

2. Put an instance of this "pic" in the first layer of the scene, with the same size as the scene, as a thumbnail.

3. Create a new layer "pic-big", then put an instance of "pic" and enter "gback" in the instance. This picture will be used as a big picture. Don't worry about its size and location now, because we will change it dynamically with ActionScript when the movie is playing.

4. Create a new layer "mask" and draw a circle with appropriate size on it. Convert it into a movie clip symbol. And change its instance to "zoom". This circle is your "magnifying glass". Right-click a layer, select Mask, and turn this layer into a mask.

Now start writing our code.

1. Click pic-small and add the following code to it:

OnClipEvent (load)

{

scale = 2; //Initialize the magnification

}

Onlipevent(mousemove)// Calculate and change the position of the big picture in real time when the mouse moves.

{

_ root . gback . _ x = _ x mouse-_ x mouse * scale;

_root.gback._y=。 _ ymouse-_ ymouse * scale;

}

On(keyPress "") // Reduce the magnification when you press PAGEDOWN.

{

scale-= 0. 1;

if(scale & lt; 1)scale = 1;

//The size and position of the picture should be reset after the multiple is changed.

_ root.gback. _ xscale = 50 * scale

_ root . gback . _ y scale = 50 * scale;

_root.gback._x=_root。 _ x mouse-_ x mouse * scale;

_root.gback._y=_root。 _ ymouse-_ ymouse * scale;

}

On(keyPress "") // Increase the magnification when pressing the PAGEUP key.

{

scale+= 0. 1;

if(scale & gt; 4) Scale = 4;

//The size and position of the picture should be reset after the multiple is changed.

_ root.gback. _ xscale = 50 * scale

_ root . gback . _ y scale = 50 * scale;

_root.gback._x=_root。 _ x mouse-_ x mouse * scale;

_root.gback._y=_root。 _ ymouse-_ ymouse * scale;

}

2. Add the following code to the first frame of the movie:

startDrag(zoom,true); //Drag the magnifying glass to lock the mouse in its center.

Ok, now we can press "Ctrl+Enter" to test our movie. You can also add some ideas to make the film more perfect.