Yup Josh is correct, creating a vector is the way to go...
The "slowing down" force you're talking about is friction (at least in
physics). If you're interested in this kind of stuff, I highly recommend
picking up a copy of Keith Peters book:
http://www.amazon.com/Foundation-Actionscript-3-0-Animation-Making/dp/1590597915/ref=sr_1_1?ie=UTF8&s=books&qid=1240464956&sr=8-1
Cheers,
On Wed, Apr 22, 2009 at 9:19 PM, Josh McDonald wrote:
>
>
> That sort of thing (a vector) is easy, once you've determined the direction
> in radians, and a speed. Let's call it pixels-per-frame, to make things
> simple. Note that this is typed in gmail, and will need tweaks!
>
> accuratePositionX = x;
> accuratePositionY = y;
>
> velocityX = Math.cos(direction) * initialVelocity;
> velocityY = Math.sin(direction) * initialVelocity;
>
> //Do every frame:
> function updatePosition():void
> {
> accuratePositionX += velocityX;
> accuratePositionY += velocityY;
>
> x = Math.round(accuratePositionX);
> y = Math.round(accuratePositionY);
>
> velocityX *= 0.9;
> velocityY *= 0.9;
>
> if (velocityX < 0.05 && velocityX < 0.05)
> stopTheAnimation();
> }
>
> Cheers,
> -Josh
>
> 2009/4/23 flexaustin
>
>>
>>
>> Does anyone know of a tutorial on actionscript and gravity. Not like
>> dropping a ball, but like google maps where you drag an item and it keeps
>> going in that direction but slowing down. So gravity in all directions
>> something like a hockey puck.
>>
>> TIA
>>
>>
>
>
> --
> "Therefore, send not to know For whom the bell tolls. It tolls for thee."
>
> Josh 'G-Funk' McDonald
> - j...@joshmcdonald.info
> - http://twitter.com/sophistifunk
> - http://flex.joshmcdonald.info/
>
>
>
--
Cheers,
Nate
http://blog.natebeck.net