06. Double-click on the evilBubble symbol in the library, and remove all but the first frame of the timeline by highlighting the frames, right-clicking and selecting Remove Frames. Delete the motion guide layer, then reposition the bubble so that its centre aligns with the origin crosshairs on the stage. Select the bubble and use the Tint colour effect to give it a colour.

07. The evil bubble doesn’t yet appear on stage; it’s in the library waiting to be used. We’re going to create lots of evil bubbles using ActionScript. Go to File > New, select ActionScript file, and save the resulting document as EB.as.

08. Enter the following code into the EB.as file (you can copy and paste it from the file Step 8 on the cover CD). This code is similar to that for the MO class, but has a few differences we’ll look at in a moment: class EB extends MovieClip { var speed; function onLoad() { _x = 800; _y = Math.random()*490; _xscale = _yscale = Math.random()*80 + 20; _alpha = 60; speed = Math.random()*5 + 5; } function onEnterFrame() { _x -= speed; if(_x < -60) { this.removeMovieClip(); } } }

09. The code we’ve just added sets up a variable called speed that represents how quickly the bubble moves across the screen. When the bubble is first created, we set it to appear off the right-hand side of the screen (at an X position of 800 pixels) and we randomly set the Y position somewhere between 0 and 490 pixels (the height of our movie). We create a random scale and speed for the bubble, then each time the onEnterFrame function runs we update the position of the bubble and if it’s moved out of sight (60 pixels to the left of the screen) we remove it.