A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Quick question

  1. #1
    Dance Monkey Dance! Doush.'s Avatar
    Join Date
    Jun 2004
    Posts
    254

    Quick question

    Hey guys,

    Just wondering if someone could help me out with a formula for easing out. I can ease in fine but I'm confused on how to ease out.

    I'm trying to get an object to move towards a point by speeding up and stopping at the point.

    So origin_x is 10 and destination_x is 200, so its last x step should be its fastest before it stops?

    Thanks
    "I layed down in my bed last night looked up at the stars, and thought to myself... Where the F*#K is my roof"

  2. #2
    Senior Member
    Join Date
    May 2006
    Location
    Manhattan
    Posts
    246
    looks like you're actually trying to do ease in...

    you can use exponential interpolation:

    PHP Code:
    function easeInbegin:Numberend:Numbert:Numberpower:Number ) : Number
    {
       return 
    begin + ( end begin ) * Math.powtpower );

    where begin is your original value, end your target value, t is a value 0 <= t <= 1 that represents the percentage through the animation time. the higher the power the slower the acceleration and the faster the end speed.
    Last edited by newblack; 05-27-2010 at 01:31 PM.

  3. #3
    Dance Monkey Dance! Doush.'s Avatar
    Join Date
    Jun 2004
    Posts
    254
    Thanks newblack. One question about the t variable. Do I increment it every time the function is called

    time = 0;
    thing.x = easeIn(0, 200, time);
    time++;
    "I layed down in my bed last night looked up at the stars, and thought to myself... Where the F*#K is my roof"

  4. #4
    Senior Member
    Join Date
    May 2006
    Location
    Manhattan
    Posts
    246
    you want it to be currentTime / duration, so when the animation starts, t = 0, and at the end it's equal to 1.

  5. #5
    Dance Monkey Dance! Doush.'s Avatar
    Join Date
    Jun 2004
    Posts
    254
    Ahh I see understood. Works a treat. Thanks heaps for your help newblack.
    "I layed down in my bed last night looked up at the stars, and thought to myself... Where the F*#K is my roof"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center