Basic tutorials for the Tween class in AS3.0

Source: Internet
Author: User

Basic tutorials for the Tween class in AS3.0

Let's write a small tutorial on the Tween class in ActionScript3.0. I 'd like to catch up with the trend. (I personally think that AS3.0 is the mainstream technology supporting interactive design in the future)
When it comes to the Tween class, it means implementing the animation of the population. In Flash CS3, Adobe has developed a set of classes for you to easily implement motion effects. This class package is located in fl. transition. Actually, these packages
The principle of the class effect in is to listen to the ENTER_FRAME event. During animation playback, the attribute of the target is changed by frame rate to produce the animation effect.
The core category of animation is the Tween class.
Let's look at some constructors of the Tween class:
Tween (obj: Object, prop: String, func: Function, begin: Number, finish: Number, duration: Number, useSeconds: Boolean = false)
These parameters represent:
1. The object to be animated
2. To change the attributes of an object, note that this value is a string.
3. How to use the animation of the property of the program compensation appeal?
4. Initial value of the object property (initial value of the program to start the population)
5. Terminal value of the object property (the final value to be filled by the program)
6. Animation duration
7. Set whether the animation duration is calculated by Frame (useSeconds = false) or by second (useSeconds = true). The default value is calculated by the number of frames.
Once the Tween object is initialized, the animation starts. The Tween animation can trigger six types of events. The most common cause is TweenEvent. MOTION_FINISH. This event is triggered when the animation ends.
The source code of AS3.0 is as follows:
Import flash. display. Sprite;
Import fl. transitions. Tween;
Import fl. transitions. easing. Elastic;
Import fl. transitions. TweenEvent;
Var mySprite: MovieClip = new Symbol ();
This. addChild (mySprite );
Var xTween: Tween = new Tween (mySprite, "x", Elastic. easeOut, 100,200, 2, true );
XTween. addEventListener (TweenEvent. MOTION_FINISH, continueMove );
Function continueMove (evt: TweenEvent): void {
Var tmpTween: Tween = evt.tar get as Tween;
If (mySprite. x> 300 ){
TmpTween. yoyo ();
} Else {
TmpTween. continueTo (mySprite. x + 50, 1 );
}
}

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.