Chapter 4. Method to the Madness

 <  Day Day Up  >  

In Chapter 3, "We're All Described by Our Properties," we covered how properties are important to the idea of a class definition. The Loan class in that chapter had variables attached to the class, including principal, rate, and years .

In this current chapter, we delve into the idea of attaching functions to the class. Just as a variable, when attached to a class, is known as a property, a function when attached to a class is known as a method. When a method is defined in a class definition, all these methods are available to any objects created from that class. For example, getURL() is a function that is defined by the MovieClip class. Every movie clip object that you create, whether with the drawing tools, the createEmptyMovieClip() method, or by subclassing the MovieClip class, will contain the getURL() method. See Figure 4.1.

Figure 4.1. The methods of the MovieClip class, as shown in the Actions panel.

graphics/04fig01.gif

As you go through this chapter, you will find that understanding methods and their benefits is essential to object-oriented programming (OOP).

 <  Day Day Up  >  


Object-Oriented Programming with ActionScript 2.0
Object-Oriented Programming with ActionScript 2.0
ISBN: 0735713804
EAN: 2147483647
Year: 2004
Pages: 162

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