Creating Equilibrium Points
by Christian Eilsøe
In this tutorial, we'll take a gander at what
simple mathematics can accomplish when used right.
With simple math, we can do all sorts of stuff,
i.e. EQ points. IF you paid attention in math
classes in grade school, this won't be new to
Below is an example
of how EQ points work. Just drag the red balls
around, and notice how the square relates to the
Example of EQ points in flash: drag the circles
Let's get on
Create a circle on the main timeline, make it
a movie clip, and name
Add the following code to ball1 in the actions
When done, select ball1, and press ctrl+D three
times, to duplicate the clip. Then we should
have 4 red balls on the stage =0)
Rename the instances, so we have ball1,
Nextly, create a small square in the middle
of our stage. You don't have to name this one
Call it the "Evil Lawnmover from hell"
for all I care *lol*.
We SHOULD now have something similar to what
I have down below:
Allrighty, time to code the square.
IF you'd listened carefully in grade school,
you'll know, that finding the "middle"
value between two other values, is quite simple.
Let's try it:
value1= 450, value2=325
EQ value = (450+325)/2 = 387.5
See, the only thing I had to do, was add
the values together, and divide by the number
of total values I had! =0) Easy huh?
now, let's make the square move!
As mentioned above, we have to add all values
and divide by the number of values we have,
We have 4 balls, and we want the square to position
itself at the "middle" point of all
4 balls. So actually, all we have to do, is
add all the x values and thereafter, all the
y values =0)
Add the following code to the square:
So there we have it =0)
Test your movie and drag around the circles!
-Christian Eilsøe a.k.a.