OOPs: More Classes

Flash creates a bare-bones outline of the class.

Notice that the name of the class is Bubble and there is one function called Bubble. This function is called the constructor.

package  {
	
	public class Bubble {

		public function Bubble() {
			// constructor code
		}

	}
	
}

We will fill in the class as follows:

package  {
	//imports
	public class Bubble extends MovieClip {
       //variables
		public function Bubble() {
			// constructor code: anything that happens ONCE at the beginning
			
		} //constructor
        //other functions
	} //class
} //package

We have added the clause extends MovieClip. Most of the classes that you create will extend MovieClip.

If you label the closing braces with a comment now, it will make it easier to keep them in the right place.

From the menu select Save and save Bubble.as in the folder that you use for all of the classes.

NEXT: Variables