Jump to content
Search Community

easing on timeline

alflasy test
Moderator Tag

Recommended Posts

Hi

I have simple timeline with few images in it and I am scrolling the timeline front and back with scrubber. works great. But I want to add easing on it. Here is the code that moves the timeline while scrubbing

 

timeline.gotoAndStop(ScrollerMC.scrubber.x*timeline.totalDuration/scroll_amount);

 

Is t possible to do it. Please let me know.

 

Thank you

Link to comment
Share on other sites

Your "timeline" is a TimelineLite or TimelineMax instance, right? If so, you could tween it from wherever it is currently to the 4-second point with a Strong.easeOut ease over the course of 0.5 seconds like this:

 

timeline.pause();
TweenLite.to(timeline, 0.5, {currentTime:4, ease:Strong.easeOut});

Link to comment
Share on other sites

Thanks you greensock, I sure you code is right but I can't get it to work. Below is my onPress event code on scruber which start draging.

 

scrubber.onPress = function() {
//timeline.stop();
startDrag(this,false,0,this._y,scroll_amount,this._y);
timeline.pause();
TweenLite.to(timeline, 0.5, {currentTime:4, ease:Strong.easeOut});
//this.onMouseMove = function(){
//timeline.gotoAndStop(scrubber._x*timeline.totalDuration/scroll_amount)
//}
};

 

if I uncomment onMoseMove then it works fine but no easing. Any suggestion please.

 

Thank you

Link to comment
Share on other sites

It sounds like you'd want the tweening in the onMouseMove function. like:

 

scrubber.onPress = function():Void {
   startDrag(this,false,0,this._y,scroll_amount,this._y);
   timeline.pause();
   scrubber.onMouseMove = onScrubberMove;
};

function onScrubberMove():Void {
   TweenLite.to(timeline, 0.5, {currentTime:scrubber._x*timeline.totalDuration/scroll_amount, ease:Strong.easeOut});
}

 

(I'd recommend avoiding nested functions, by the way - they can cause problems since they're generally deleted when the parent function finishes running).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...