Flash import MX. transitions. Tweens; Use

Source: Internet
Author: User

Flash MX. transitions. Tween; can be similar to the effect of the compensation animation; import this class:

Import MX. transitions. Tween;

Use the new tween () method. New tween () method format:
New tween, the type of the population length)

The following describes the parameters of the new tween () method.

MC:This is the MC Luo for applying the population.

Attributes of MC to apply the population:In practice, the compensation animation changes the object attributes at a certain time. For example, the displacement is to change the _ x or _ y attributes, and other attributes such as _ xscal and _ Alpha. The names of these attributes.

Easing effect:We have introduced this in the previous section.

Attribute initial value:For example, if we want to use the _ x property of the population room, and we want to create an animation for the object to move from the left of the stage to the right, the initial value of _ X should be very small, such as, 50, etc, that is, the _ x value of the object on the left of the stage.

Attribute end value:The attribute value at the end of the population period, for example, the value of _ x when the object moves to the right of the stage.

Length of the population:There can be two representation modes: Second or frame, but here it is only a numerical value. The second or frame-based compensation is determined by the following parameter.

The type of the population length:The second or frame is used to calculate the intercept. If the value is true, the second is used for calculation. If the value is false, the frame is used for calculation.

For example, let's create

A complementary animation moves a ball from the left of the stage to the right:
Draw a ball and convert it to MC. The instance name is ball_mc.

Open the frame action panel and enter the following code:

Import MX. transitions. Tween;
Import MX. transitions. Easing. *; // because the easing effect is used, the easing class is also imported
New tween (ball_mc, "_ x", none. easenone, 20,500, 3, true );

In the test video, the ball moves from the left side (20 images) to the right side (500 pixels) for 3 seconds.

The above effect has no easing effect. If you want to add a easing effect, there is a easing class called regular which will implement the slowing effect. We will call the easein Method for it, that is to say, it slows down at the beginning of the population period. Does it achieve the effect from slow to fast? Change the code to the following:

Import MX. transitions. Tween;
Import MX. transitions. Easing .*;
New tween (ball_mc, "_ x", regular. easein, 20,500, 40, false );

Test the video. We can see that the ball moves from slow to fast from left to right. In this Code, three parameters are changed. One is the easing effect, the other is that the length of the population is 40, and the other is the length type. The other is false, in this way, the length of the tween is no longer 3 seconds, but 40 frames.

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.