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.

Table 11-3. The class names for common Flash UI components

Component

Class definition name

Linkage symbol name

CheckBox

FCheckBoxClass

FCheckBoxSymbol

ComboBox

FComboBoxClass

FComboBoxSymbol

ListBox

FListBoxClass

FListBoxSymbol

PushButton

Get Flash Remoting: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.