It is possible to add additional behavior to a movie-clip symbol by creating and linking a custom class to it. Typically the class will listen for, and respond to events dispatched by the movie clip. Of those available, Event.ENTER_FRAME
is the most widely used, providing a means to programmatically update the movie-clip's appearance on every frame redrawn.
We will write a custom class that makes each of the bubbles from the latest version of our example app float upwards.
Let us write the custom class and link it to each of the bubbles:
Within Flash Professional select File | New (Ctrl + N | Cmd + N). From the New Document panel, create an ActionScript 3.0 Class and name it Bubble. A skeleton class will be created.
Add the following code to the class:
package { import flash.display.Sprite; import flash.events.Event; public class Bubble extends Sprite { private var _speed:Number = 1; public function Bubble() { addEventListener...