Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 116

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

Advertisement

Methods that are implemented in the custom component must have the same return type as
their corresponding methods in the interface. If no return type is specified in the interface, the
implementing methods can declare any return type.
About implementing IMXMLObject
You cannot define a constructor for an MXML component. If you do, the Flex compiler
issues an error message that specifies that you defined a duplicate function.
For many types of Flex components, you can use an event listener instead of a constructor. For
example, depending on what you want to do, you can write an event listener for the
,
preinitialize
initialize
These events are all defined by the UIComponent class, and inherited by all of its subclasses.
If you create an MXML component that is not a subclass of
advantage of these events. You can instead implement the
MXML component, and then implement the
following example shows:
<?xml version="1.0"?>
<!-- mxmlAdvanced/myComponents/ObjectComp.mxml -->
<mx:Object xmlns:mx="http://www.adobe.com/2006/mxml"
implements="mx.core.IMXMLObject">
<mx:Script>
<![CDATA[
// Implement the IMXMLObject.initialized() method.
public function initialized(document:Object, id:String):void {
trace("initialized, x = " + x);
}
]]>
</mx:Script>
<mx:Number id="y"/>
<mx:Number id="z"/>
<mx:Number id="x"/>
</mx:Object>
116
Creating Advanced MXML Components
, or
creationComplete
IMXMLObject.initialized()
event to replace the constructor.
UIComponent,
IMXMLObject
interface in your
you cannot take
method, as the

Advertisement

Table of Contents
loading

Table of Contents