General process for writing a class file
Use the following general process when writing the ActionScript for a component. Some steps may be optional, depending on the type of component you create.
This process is covered in more detail in the rest of this chapter.
- Import all necessary classes.
- Define the class using the
class
keyword; extend a parent class, if necessary.
- Define the
symbolName
and symbolOwner
variables; these are the symbol name of your ActionScript class and the fully qualified package name of the class, respectively.
- Define your class name as the
className
variable.
- Add versioning information.
- Enter your default member variables.
- Create variables for every skin element/linkage used in the component. This lets users set a different skin element by changing a parameter in the component.
- Add class constants.
- Add a metadata keyword and declaration for every variable that has a getter/setter.
- Define uninitialized member variables.
- Define getters and setters.
- Write a constructor. It should generally be empty.
- Add an initialization method. This method is called when the class is created.
- Add a size method.
- Add custom methods or override inherited methods.