You have done what ah, the cost of half a day to get out of the effect is too no level, give me a rebound effect let batting practice appreciate. Although your heart straight drums, but see passers-by a classmate sincere eyes, or lofty road. Hey, the book to the side hate less ah, who let me math did not learn it, Leng used Dickens, also did not make this effect.
So you just need to ...
Yes, the easing class for lazy people.
Now let's take a look at how to make use of this good thing.
When it comes to classes, people who have the basics of programming, the first thing to think of is object-oriented, no programming base, certainly confused. Because this tutorial mainly facing the latter, so first hit the gas, in fact, class this thing, although this time we are the first grand mention, but, you are actually always dealing with the class. But you don't know. Even now, you don't need to know what a class is, the task of this section is to tell you how to use it.
In the Flash as2.0, there are two classes associated with easing, one called tween class, and one called easing class. With these two things, you can make way for a man to admire the animation.
Before using these two classes, we have to load it in and write these two sentences in the first line of the program:
| The code is as follows |
Copy Code |
Import Tween Class
Import Mx.transitions.Tween;
Import easing class
Import mx.transitions.easing.*; |
So that when your program runs, these two classes are loaded in.
Import is the meaning of importing classes.
And the mx.transitions in the back. This is the path that this class holds. Tell Flash where to find these two classes, because they are installed with Flash to your computer, so this path is fixed.
Of course, you can not write these two words, but I suggest you write, because not to write, every time you mention them, you have to put them in front of the line of the road written.
Let's say this:
| The code is as follows |
Copy Code |
Sometweenid=new Mx.transitions.Tween (...)
|
But with these two words, you're simple.
| The code is as follows |
Copy Code |
sometweenid= new Tween (...)
|
This is like you and you mm chat, referred to passers-by a, you mm must be very confused asked, is which passers-by a ah? So you have to say, it's the one that I'm looking at with a super upset. But if you start by telling mm, I now want to talk to you about that let me uncomfortable passers-by a, each time I mentioned him, it is not so troublesome, call him a small one on the line.
Well, that's a lot of crap. Now let's take a look at how the first class is used.
| code is as follows |
copy code |
sometweenid = New Tween (object, property,function,begin,end,duration,useseconds)
|
First, explain the meaning of some of the parameters inside.
Object: Refers to tween objects, which is the target.
Property: string, which means that when you use it, enclose them in quotation marks, which is the attribute you want to apply the effect to, such as "_x", "_y" and so on.
Function:easing easing type. (Can't read it later)
Begin: Numeric value, the initial value of the object, which is the start of the easing.
End: Numeric value, the values that the easing ends.
Duration: Easing time.
Useseconds: Is a Boolean value that determines whether the easing time is expressed in seconds or by frame numbers. True indicates the use of seconds, false with frames.
See here you know, tween class is mainly to control who, control what, how long time problem.
As to how to ease the movement, it is another class of work: easing
Below we drag the easing class out to the parade.
Back: An extended animation that is outside the range of one or two end points, similar to an overflow effect
Bounce: In the transition range of one or two end points, the rebound effect is added, the number of springback depends on the time of the motion process, and the number of rebound times is relatively long.
Elastic: An elastic effect that occurs outside the transition range of one or two end points, and the effect of the elastic force on the process time of an immature motion
Reguler: Add a deceleration effect at one or two end points, this feature will help you to speed up the deceleration effect
Strong: Add deceleration effect at one or two end points, this effect is similar to regular, the difference is more obvious
None: adding uniform motion at the start point to the end point has no effect.
If you do not understand the above description, do not worry, continue to look down.
The above mentioned six effects, and these six effects, but also includes three kinds of transition mode
Easein: In the beginning of the transition to produce effect, that is, movement began to appear this effect.
Easeout: At the end of the transition to produce effect, the movement to end when this effect occurs.
Easeinout: Both begin and end in effect.
Well, it's no use talking about it, let's try it on the pitch. If you don't understand the front, try it on the stage and you'll see.
Create a movie clip in the library. Then load it into the scene.
| The code is as follows |
Copy Code |
|
This.attachmovie ("Mymc", "MYMC", this.getnexthighestdepth (), {_x:20,
_Y:100}); |
Do not understand this sentence, go back to see the first chapter of this tutorial.
Then we use the tween class to do the easing effect
| code is as follows |
copy code |
myball = new Tween (MYMC, "_x", Elastic.easeout, 0, 3, true);
|
Now we're going to explain the code above, MYMC Needless to say, because you want to let MYMC produce easing effect, so, this place is mymc,_x, by changing the x axis of the property value, to achieve the effect of easing, of course, out of _x weeks, we have mentioned the properties of the film clips, Can be used, if you have time, then take them out to try it. Elastic.easeout, did you see this place? Use is we just mentioned easing class, elastic easing effect, easeout transition way, they two and up meaning, is to let MYMC at the end of the movement produced rebound effect. 20, the movie clip starts from 20 movement, 300, the movie clip finally stops at 300 position, 2, the time is 2,true, indicates that calculates the time the unit is the second.
I'm sure I don't have to say that you've tested me on this piece of code. Now you can try the various effects we've just mentioned, and we'll see how they might feel.
Here you can see that these two classes are really lazy and intimate, first of all, it has cleared the loop in the class, so you don't have to worry about the problem of circular cleanup anymore. Second, if you have finished a rebound effect, the lovely customer saw later, but said, this effect to see me dizzy, can you give me a relaxation point? At this point you only need to change the elastic to strong or reguler, and another effect will come out. The rest of the time, you can drink tea, to cool look at the tutorials and so on, it is home travel, the necessary tool for the lazy girls.
Don't be busy with excitement, next, we say two more useful things about easing classes, the first is onmotionfinished, this tells the program, if the easing is over, what should be done. If you don't know this function, but when you want to make a movie clip, the pop-up tip tells you it's over, and it seems like a lot of trouble, at least for now, your knowledge isn't enough to make you do it. But with the onmotionfinished, everything became simple.
next to the code above, continue to write:
| The code is as follows |
Copy Code |
|
Myball.onmotionfinished=function () {
Trace ("Slow motion is over!") ");
} |
Take a look at what effect. By the way, here is the role of trace, the role of trace in the test, in the output panel output () Inside the content, you have already seen its role, we will often use it to test our program.
In addition to onmotionfinished, there is also a way to make your movement move in another direction, which is called Continueto (), which has two parameters, the first parameter is the next target point, and the second parameter is the elapsed time. The equivalent of tween inside the finish,duration, we still come to the scene to try, we understand.
Change the code above to
| code is as follows |
copy code |
|
Myball.onmotion Finished=function () {
Myball.continueto (2);
} |