in Tutorials

The Throw Slider tutorial is now live

I just finished uploading a new tutorial that shows you how to create a regular slider and then take it to another level by adding throw physics to it. Trust me, this is not you parent’s slider! Most of what I’ve learned about animation physics comes from Keith Peter’s excellent ActionScript Animation book. Check it out at You can see the final result below.

Update: There was a slght bug where the slider wouldn’t come to a complete stop when moving to the left. This was because vx never actually reached zero. This is easily fixed by adding the following line of code. I updated the tutorial files with the fix.

if(Math.abs(vx) < 0.5) vx = 0;


Write a Comment



  1. Very nice work, very sleek.

    One thing, you might want to add an event listener that stops the drag if the mouse leaves the stage.

    One other thing, you’re linking to the wrong tutorial.

  2. Nice tutorial – one thing i noticed though…

    If you throw the slider so that it stops while moving towards left – ull notice the slide never stops and continues move.

  3. Nice, but when you release the slider to the left it keeps moving one pixel at a time for some time. This does not happen when you release it to the right. I got the same error when I built a simple game where a space ship was supposed to decelerate when you did not press any of the arrow keys – it kept moving slowly pixel by pixel to the left.

  4. great work as always.

    in this post ‘new tutorial’ link needs a little fix! It takes you to “Getting Started With AIR on Linux” tutorial instead of “The Throw Slider”.


  5. Amazing and very creative! Except I think it would be even better if there was a cap to the minimum speed since after throwing it (in some cases), the slider continues to inch along for a while. Maybe if the velocity is less than 1 or 0.5 it should be set to 0 or something.

  6. It’s fake, or your slider is busted! Sliders are never that loose. Haha, cool, I can’t way to introspect your throw logic! Thanks other Lee

  7. This cool. Stopping the loop when it reaches a certain point between the last movement would be an added feature to help users learn. All too often i see those loops that eat up cpu in a lot of Flash content on the web. I think a tutorial on that could help lot of new designer/developers.

    I normally use a range within the loop to check against how much the object will have moved since the last movement. That way the loop stops at the desired location within a few pixels, and can be stopped on an integer.

    Ok, I’m going on and on about nothing, another great tutorial Lee.

  8. Thanks for letting me know about the bug guys. I just updated the post and the tutorial files with the fix. If you refresh your cache you will see that the example above works correctly now.

  9. I just spent more time than I’m willing to admit playing around with that demo. For some reason there’s a lot of voodoo surrounding using animation physics but once you learn how to do it it’s actually really easy and it can add so much to a project. Thanks for sharing this tutorial!

  10. … What exactly is an object (in actionscript)? I never quite understood that. Anywhere I can get a good definition?
    Thanks for all your tutorials!

  11. what does “parent’s slider” mean?
    how to translate those words?
    thank you.

    ?????????????????????????????????????????,??$parent????$??????????????????????Keith Peter?<>???????,????????????????


    if(Math.abs(vx) < 0.5) vx = 0;

  12. Great Tutorials, Lee!

    The only gleech that still remains is that if you pull the slider to throw it but leave the stage while on hold, the slider will follow the mouse once again, when you return to the stage. (I hope the explanation doesn’t suck… >_<‘ )

  13. That is funny – your slider not stopping in one direction. I ran into that problem back in Flash 5. Nice to see that it still does that. :)