Actionscripted Mouse/Object Movement--Tutorial

Intro...
In the example when the user clicks the mouse, the object goes to the place clicked, slowing down as it nears. The main challenge is to figure out what number you could add to the objects postion so it can go in both negative and positive directions.

The Idea..
The answer is quite simple. We must generate a different factor each time.

How?
Basically we first decide on a new place to go. Lets say (on x axis only) We want to goto 500 px. We are at 200 px. We need to add to our position to get us there. So we use this equation to get the factor we add to our current position...

(place we want to go - our current location)/10

or with numbers

(500-200)/10 which is equal to 30.

We divide the difference by 10 because if we didn't we would have 300. Then we would be brought to our destination in one turn, thus there is no movement. We add this factor to our current x pos. until we get to 500
But just say we want to goto 100px. Well, we can use the same formula. **(100-200)/10** which is equal to -10. Huh, a negative? Yup! We need it to be negative, so we that when we add on the factor, it will actually decrease our x pos. bringing us from 200 to 100...

Slowing Down
Ok, now we understand why we move where we do, but how do you get the slowing down movement. Well, look at it this way. Basically, every frame, we are adding the special factor to our currect x pos. This factor is actually the distance we are from the place we are going. Then we dampen it by dividing to make it smaller number, to add on to wherever we are. Now at first, the distance between us and the new position is quite big. Thus we are adding a bigger factor to our position, and we go faster. But as we approach our destination, the distance between us and the destination grows less and thus the factor grows smaller. We add less to our current position, thus making it look like we are slowing down, covering less distance...

That's it!!
You may have thought this stuff was hard, but it's quite easy, right? You can use this type of stuff in menus. It makes your sites much more interesting, interactive and with smaller filesizes because there is less tweening. Happy flashing.