I've often wondered this myself, and while naturally there's a way to code it out yourself, you'll probably pull a lot less hair out by using a physics engine someone else has written. This may sound cheap at first, but if you think about it, even most major game studios license third-party physics software for their games. Google 'ActionScript Physics Engine' and you should find a link to a package called APE. There are plenty of other engines out there, but this was the first one I was introduced to. They take some reading to understand how they work, but the results you can get from them are fantastic. I hope this helps "get the ball rolling," so to speak!