The movie clip object is unique among all other objects because it can be created manually or with ActionScript. It also has a timeline that is independent from the main timeline. This means that you can have content on a movie clip's timeline that runs on its own, unconnected from its parent timeline. The movie clip object also has an extensive list of properties, methods, and events. It can also handle button events, so you can see why it is the most popular object to use in Flash. In this example, we will create a movie clip manually, and then control it with ActionScript.
The preceding code first creates a variable to control the speed of the circle. Then it simply creates a callback function that continually fires. In this callback, we get the distance between the circle and the mouse on both the horizontal and vertical plane. We then set the circle's position based on that distance. Now test the movie and move the mouse around on the screen. You will see that the circle_mc movie clip follows the mouse wherever it goes while still on the screen. You can find more information on the movie clip object in Chapter 13, "The Movie Clip Objects." |