Flash CS3 Documentation |
|||
| Programming ActionScript 3.0 > Object-oriented programming in ActionScript > Basics of object-oriented programming | |||
Object-oriented programming (OOP) is a way of organizing the code in a program by grouping it into objects--individual elements that include information (data values) and functionality. Using an object-oriented approach to organizing a program allows you to group particular pieces of information (for example, music information like album title, track title, or artist name) together with common functionality or actions associated with that information (such as "add track to playlist" or "play all songs by this artist"). These items are combined into a single item, an object (for example, an "Album" or "MusicTrack"). Being able to bundle these values and functions together provides several benefits, including only needing to keep track of a single variable rather than multiple ones, organizing related functionality together, and being able to structure programs in ways that more closely match the real world.
In practice, object-oriented programming has two parts. One part is the strategies and techniques for designing a program (often called object-oriented design). This is a broad subject and is not discussed in this chapter. The other part of OOP is the actual programming structures that are available in a given programming language to build a program using an object-oriented approach. This chapter covers the following common tasks in OOP:
The following reference list contains important terms that you will encounter in this chapter:
private and public are attributes. A private method can be called only by code within the class, while a public method can be called by any code in the program..), which in ActionScript (and many other programming languages) is used to indicate that a name refers to a child element of an object (such as a property or method). For instance, in the expression myObject.myProperty, the dot operator indicates that the term myProperty is referring to some value that is an element of the object named myObject.As you're working through the chapter, you may want to test some of the example code listings for yourself. Because the code listings in this chapter deal primarily with defining and manipulating data types, testing the examples will involve creating an instance of the class being defined, manipulating that instance using its properties or methods, and then viewing the values of the that instance's properties. For viewing those values, you'll want to write values into a text field instance on the Stage, or use the trace() function to print values to the Output panel. These techniques are described in detail in Testing in-chapter example code listings.
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00000059.html