Cool Mouse [moving the target]

Source: Internet
Author: User
Tags array length

Before learning, let's review what we used previously (feature code 07 <changes>)
Target moving formula:

Mc. Current coordinate + = (mc. Target coordinate-mc. Current coordinate) * A slow constant (0 <A <1)


For example:

There is a video clip on the stage. The instance name is mc and it is moved to the position x = 400, y = 300.
Mc. Tox = 400;
MCS. Toy = 300;
Mc. onEnterFrame = function (){
This. _ x + = (this. Tox-this. _ x) x 0.3;
This. _ y + = (this. Toy-this. _ y) * 0.3;
// Update the coordinates of each instance, which can be understood:
// The X coordinate of the instance = your X coordinate + (the X coordinate of the target-your X coordinate) * 0.3
// Y coordinate of the instance = Your Y coordinate + (the Y coordinate of the target-your Y coordinate) * 0.3
};

Instance 1

Ideas:
1. Copy the Num mouse and decrease the transparency of the mouse (if I is increasing, N-I is decreasing );
2. Use the Num mouse as the current mouse, and the rest are followed;
3. The principle of following is that the previous mouse position is used as the target coordinate to move the last mouse forward.

Step 1:

CoolMouse1.jpg

Draw a mouse, save it as a video clip, connect-> export-> the identifier "mouse"
Step 2:
Add the AS code:
Mouse. hide ();
// Hide the original mouse
Var Num = 10;
// Number of mouse trails
For (var I = 0; I <Num; I ++ ){
_ Root. attachMovie ("mouse", "m" + I, I );
// Copy the video clip with Num mouse
This ["m" + I]. _ alpha = (Num-I)/Num * 100;
// Sets the gradient effect, with the transparency of each mouse decreasing
}
_ Root. onEnterFrame = function (){
This ["m" + 0]. _ x = _ xmouse;
This ["m" + 0]. _ y = _ ymouse;
// Set this ["m" + 0] as the current mouse
For (var I = 1; I <Num; I ++ ){
This ["m" + I]. _ x + = (this ["m" + (i-1)]. _ x)-this ["m" + I]. _ x) * 0.5;
This ["m" + I]. _ y + = (this ["m" + (i-1)]. _ y)-this ["m" + I]. _ y) * 0.5;
}
// Place the last mouse cursor following the position of the previous mouse, and move the cursor forward slowly.
};

Instance 2

Ideas:
1. The method is similar to instance 1;
2. Changed the mouse style;
3. Make a small mouse more transparent and a large mouse more transparent (if I is increasing, N-I is decreasing ).

Step 1:

CoolMouse1.jpg

Draw a mouse, save it as a video clip, connect-> export-> the identifier "mouse"
Step 2:
Add the AS code:
Mouse. hide ();
// Hide the original mouse
Var Num = 10;
// Number of mouse trails
For (var I = 0; I <Num; I ++ ){
_ Root. attachMovie ("mouse", "m" + I, I );
This ["m" + I]. _ xscale = this ["m" + I]. _ yscale = I/Num * 100;
// Increase the mouse size
This ["m" + I]. _ alpha = (Num-I)/Num * 100;
// Decrease the transparency of the mouse
}
_ Root. onEnterFrame = function (){
This ["m" + 0]. _ x = _ xmouse;
This ["m" + 0]. _ y = _ ymouse;
For (var I = 1; I <Num; I ++ ){
This ["m" + I]. _ x + = (this ["m" + (i-1)]. _ x)-this ["m" + I]. _ x) * 0.5;
This ["m" + I]. _ y + = (this ["m" + (i-1)]. _ y)-this ["m" + I]. _ y) * 0.5;
}
};

Instance 3

Ideas:
1. The method is similar to instance 1;
2. Changing the style of the mouse follows is also the key to enclose the mouse with a circle;
3. Change the rotation of each mouse.

Step 1:

CoolMouse1.jpg

Draw a mouse, save it as a video clip, connect-> export-> the identifier "mouse"
Note: there must be a certain distance between the mouse and the registration point, which is the key to forming a circle.
Step 2:
Add the AS code:
Var Num = 30;
// Number of mouse trails
For (var I = 0; I <Num; I ++ ){
_ Root. attachMovie ("mouse", "m" + I, I );
This ["m" + I]. _ rotation = I * 24;
// Set the initial rotation angle
This ["m" + I]. _ alpha = (Num-I)/Num * 100;
}
_ Root. onEnterFrame = function (){
This ["m" + 0]. _ x = _ xmouse;
This ["m" + 0]. _ y = _ ymouse;
This ["m" + 0]. _ rotation + = 10;
For (var I = 1; I <Num; I ++ ){
This ["m" + I]. _ x + = (this ["m" + (i-1)]. _ x)-this ["m" + I]. _ x) * 0.5;
This ["m" + I]. _ y + = (this ["m" + (i-1)]. _ y)-this ["m" + I]. _ y) * 0.5;
This ["m" + I]. _ rotation + = 10;
// Turn all the mouse
}
};

Flash Charging: for loop array reverse storage
Var Len = 20;
// Array length
Var A: Array = new Array (Len );
For (var I = 0; I <Len; I ++ ){
A[I] = Len-I;
// A [Len-i-1] = I;
}
Trace ();

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.