Finally, we want the distance between the objects, when the mouse is located inside the box, to be the same. In order to do this, we need to calculate an average distance between the objects. For this purpose, we need to find the space filled by the objects (“filledSpace”), which is the sum of all the heights (except for the first and last, since they are empty), and the total space between the first and last object (“totalheight”). The space not filled by the object is then the total height minus the filled space (“gapSpace”). To find the average, we divide this variable by the total number of objects (“avgDistance”). Having calculated the average distance, we want to apply this value to each object by using Set Property (this is not done for the first and last object, since these are empty movie clips and thus our starting value in the loop is the first object plus one. We loop while this starting value is smaller or equal to the ending value, which is the last item minus one). When applying the value, the object is placed according to the position and height of the previous movie clip plus the average distance.
The author wrote this tutorial to explain the infamous effect originally created by Joshua Davis of www.praystation.com. The tutorial was written with his personal permission and the source is simply a modification of the file available at PrayStation.com.