Enhancing a Standard Control
In the formal, object-oriented sense of the word, to extend an object means create a subclass that adds to the features of a given superclass. Here we use to term interchangeably with the more informal word enhance, by which we mean customizing an object’s feature set either by adding methods to an existing class or by modifying a class to create a new one with the desired features.
It is often handy to enhance existing components that may lack the basic features for interacting with remote services. You can simply add the functionality to the prototype of the component, or overwrite the existing functionality. The basic syntax is:
FComponentNameClass.prototype.myMethod = function (args) { // Method code goes here };
The advantage of defining the method on the prototype is that it will be available for all instances of the component.
The class names of most components follow the convention of using a capital F (Flash), the component name, and then the word Class. If you are in doubt about the name of the component class, you can check the component definition in the Library. For example, a CheckBox class definition is named FCheckBoxClass. Other components have similar names, as shown in Table 11-3.
|
Component |
Class definition name |
Linkage symbol name |
|
CheckBox |
FCheckBoxClass |
FCheckBoxSymbol |
|
ComboBox |
FComboBoxClass |
FComboBoxSymbol |
|
ListBox |
FListBoxClass |
FListBoxSymbol |
|
PushButton |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access