Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 32

Creating and extending flex 2 components
Hide thumbs Also See for FLEX 2 - CREATING AND EXTENDING COMPONENTS:
Table of Contents

Advertisement

Defining methods
Methods define the operations that your class can perform. You define methods in the body of
the class. Your methods can override a method of a superclass, or define new functionality for
your components.
If the method adds new functionality, you define it using the
following example shows:
public function myMethod():void {
// Method definition
}
If you define this method as a public method, users of the class can call it.
You can also define private methods, as the following example shows:
If a function takes no arguments, ensure that you specify its argument list as empty
parentheses (), not as (void). The latter specifies a single argument of type Object named
void.
If a function, other than a constructor, returns no value, you must specify a return value of
void. If you omit the return type, the compiler issues a warning.
private function internalMethod():void {
// Method definition
}
Private methods are for internal use by the class, and cannot be called by users of the class.
If the method overrides a method in a superclass, you must include the
and the signature of the method must exactly match that of the superclass method, as the
following example shows:
override protected function createChildren():void {
// Method definition
}
Your methods may take required or optional arguments. To make any of the arguments
optional, assign default values to them, as the following example shows:
override public validate(value:Object = null,
supressEvents:Boolean = false):ValidationResultEvent {
// Method definition
}
If the method takes a variable number of arguments, use the "..." syntax, as the following
example shows:
function foo(n:Number, ... rest):void {
// Method definition
}
32
Using ActionScript to Create Components
keyword, as the
function
keyword
override

Advertisement

Table of Contents
loading

Table of Contents