Creating springs with ActionScript
Welcome to the fifth tutorial in this series on scripted motion. In this tutorial, we’ll look at an effect that you may have seen in some Flash movies - a spring. The spring effect allows you to drag a movie clip that springs backwards and forwards and finally settles back in its original position. This effect is much easier to achieve than you might think and I’ll show you how in this tutorial. We’ll work through some examples, create a function and a text heading that uses a spring on each letter. You’ll learn about multi-dimensional arrays and calling functions at specified time intervals using setInterval.
Earlier tutorials have looked at motion in a straight line and in a circle, fades and rotations and adding inertia and gravity effects. You won’t need to have completed them before moving on to this tutorial. I've assumed that you are using Flash MX or Flash MX 2004 and that know how to add ActionScript to a movie. I've used ActionScript 1.0 for the examples.
You can download the source files for the tutorial from the blue Properties box that contains the article PDF. There's a heading titled Code Download and you can click the Details link next to it to get the zip file. The download includes the starter files you'll need as well as the completed files.
Note: If you have difficulties downloading the source files or PDF, you might have a problem with your cookies. Delete the cookies from your machine and try again. In Internet Explorer, you can do this by choosing Tools > Internet Options… and clicking the Delete Cookies… button on the General tab.