Use the mouse to control the animation of the picture Movement Effect

Source: Internet
Author: User

The production method is very simple:

First, prepare a large image (the image should be as big as possible), import it to the Flash Library, create a video clip map, put the image here, and adjust it to the appropriate position.

 

Create a video clip and create an arrow.

 

Return to the home scene and add the following code in the first frame:

Mouse. hide ();
_ Root. attachMovie ("map", "map", 1 );
_ Root. attachMovie ("the_arrow", "the_arrow", 2, {_ x: 250, _ y: 175 });
The_arrow.onEnterFrame = function (){
This. _ x + = (_ xmouse-this. _ x)/5;
This. _ y + = (_ ymouse-this. _ y)/5;
Dist_x = this. _ x-250;
Dist_y = this. _ y-175;
Angle = Math. atan (dist_y/dist_x)/(Math. PI/180 );
If (dist_x <0 ){
Angle + = 180;
 }
If (dist_x> = 0 and dist_y <0 ){
Angle + = 360;
 }
This. _ rotation = angle;
Deltax =-(this. _ x-250)/90;
Deltay =-(this. _ y-175)/90;
Map. _ x + = deltax;
Map. _ y + = deltay;
If (map. _ x & gt; 1000 ){
Map. _X = 1000;
 }
If (map. _ x <-500 ){
Map. _ x =-500;
 }
If (map. _ y> 1000 ){
Map. _X = 1000;
 }
If (map. _ y <-650 ){
Map. _ y =-650;
 }
};

Save the test! Here we will show you how to import only one small image for network reasons.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.