Chapter 19. Emulating the Natural World: A Poet s Introduction to Physics


Chapter 19. Emulating the Natural World: A Poet's Introduction to Physics

graphics/chic01.gif

The world around you is controlled by laws that enable you to predict the behavior of objects under specific conditions. You know that if you push a ball hard enough on an even surface, it will start to roll, but that it will eventually come to a stop. A ball will roll downhill, gaining momentum as it progresses. A rubber ball has more bounce than a lead ball. If the ball hits a wall, it stops, breaks through the wall, or bounces off the wall in another direction. These are all things you know intuitively; you see them in action in your daily life. What you might not understand is why objects act this way.

If you understand a little bit about how these laws work in the real world, you can adapt them to control the behavior of objects in your Flash presentations. This lends a more realistic feel to your movies.

Although you can emulate the behavior of physical objects by using tweening and frame-by-frame animations, scripting the behavior is more effective. In this chapter, you learn how to do the following:

  • Control the speed and acceleration of objects on the Stage. Moving objects around the Stage with ActionScript is not at all difficult. You'll see how you can give an object motion with button or key presses.

  • Throw objects. You also can use ActionScript to let you pick up an object and throw it across the screen.

  • Mimic elastic behavior. Elastic behavior also is fairly easy to do with Flash. You can make your objects snap back into place.

  • Detect collisions with walls and other objects. After you have the basics covered, you're ready to move into detecting when objects collide and what to do with them when they do.

You start by getting acquainted with a few simple concepts, and you'll build from there.



Inside Flash
Inside Flash MX (2nd Edition) (Inside (New Riders))
ISBN: 0735712549
EAN: 2147483647
Year: 2005
Pages: 257
Authors: Jody Keating

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net