![]() ![]() ![]() | |
![]() | |
![]() | |
![]() |
Continuing with the real-world analogy, consider that there are cats of different colors, ages, and names, with different ways of eating and purring. But all cats belong to a certain class of object, an object of type "cat." Each individual (real-world) cat is an instance of the cat class type.
Likewise, in object-oriented programming, a class defines a blueprint for a type of object. The characteristics and behaviors that belong to a class are referred to as members of that class. The characteristics (in the cat example, name, age, and color) are called properties of the class, which are represented as variables; the behaviors (eating, sleeping) are called methods of the class, and are represented as functions.
For example, you could create a Person class, and then create an individual person that would be an instance of that class, also called a Person object. The Person object would contain all the properties and methods of the Person class.
In ActionScript, you define a class with the class
statement (see Creating and using classes). ActionScript includes a number of built-in classes, such as the MovieClip, TextField, and String classes. For more information, see Using the Built-In Classes.
![]() | |
![]() | |
![]() | |
![]() ![]() ![]() |