AS2 - rewind timeline
- Started
- Last post
- 5 Responses
- tasty
I have a button on my stage...
On press, I want it move an image across the screen, on release I want it to move in back to it's 1st position.
I'm thinking I make a motion tween that it starts to play when you press it...easy. But how do I make the time line rewind?
- must_dash0
If you make an image with a symmetrical timeline... so say the endframe of the image is frame 50... when you release the mouse and it is only at 25, then you jump to 50 + 25 and stop at 100.
- fyoucher10
MC Tween frameTo function might be the easiest solution for you if you're a noob to AS2.
http://hosted.zeh.com.br/mctween…
There's also other tweening engines that'll do the same thing (Tweener, Greensocks TweenMax, etc etc). However, this one is probably the easiest to implement for you.
Download the AS file and put it next to your FLA.
In the frame where you have your code, insert the following:
#include "mc_tween.as"
(or whatever the AS file is called)Then use code like this to do what you want. It'll basically be simulating a video scrubber with the timeline
myButton.onPress = function(): Void {
anim_mc.play();
}
myButton.onRelease = function(): Void {
anim_mc.frameTo(1, 1, "linear");The parameters for the frameTo function are as follows:
1st parameter is the frame number you want to go to.
2nd parameter is the duration you want the playhead to take to get back to that frame
3rd is the kind of easing you want to use.Check out the site for more detailed documentation.
}- whoops one of the end brackets in that code got pushed to the very end of the post...fyoucher1
- WeLoveNoise0
agree with fyoucher1 - use greensock and declare your x/y positions
will make the animation alot smoother and accurate- dnt have to use GS
cud just be a simple AS prototypeWeLoveNoise
- dnt have to use GS
- tasty0
thanks fyoucher1 - u rock.