Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 29

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

Advertisement

You call the
super()
initialize the inherited items from the superclass. The
statement in your constructor; otherwise, the inherited parts of the superclass might not be
properly constructed. In some cases, you might want to initialize your class first, and then call
.
super()
If you do not define a constructor, the compiler inserts one for you and adds a call to
. However, it is considered a best practice to write a constructor and to explicitly
super()
call
, unless the class contains nothing but static members. If you define the
super()
constructor, but omit the call to
of your constructor.
In the following example, you define a constructor that uses
constructor:
package myComponents
{
// Import necessary classes
import mx.core.Container;
import mx.controls.Button;
// Import all classes in the mx.events package
import mx.events.*;
// Class definition goes here.
public class MyButton extends Button {
// Public constructor.
public function MyButton()
{
// Call the constructor in the superclass.
super();
}
// Define properties and methods.
}
}
You cannot define a constructor for an MXML component. For more information, see
"About implementing IMXMLObject" on page 116
method within your constructor to invoke the superclass's constructor to
super()
method should be the first
super()
, Flex automatically calls
super()
at the beginning
super()
to call the superclass's
Using ActionScript
29

Advertisement

Table of Contents
loading

Table of Contents