Using Actionscript - Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual

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

Advertisement

You then specify the namespace definition for the component, as the following example
shows:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myFormatters.dataFormatters.*">
<!-- Declare a formatter and specify formatting properties. -->
<MyComp:SimpleFormatter id="upperFormat" formatString="upper"/>
...
</mx:Application>
Using the import statement
You use the
statement to import any classes that your class requires. Importing adds a
import
reference to the class so that you can access classes defined by the import. Classes that you
import must be located in the ActionScript classpath for your application.
You import the classes referenced by your custom component as part of its implementation, as
the following example shows:
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.
// You can now create an instance of a Container using this syntax:
private var myContainer:Container = new Container();
}
There is a distinct difference between including and importing in ActionScript. Including is
copying lines of code from one ActionScript file into another. Files that you include must be
located relative to the file performing the include, or use an absolute path. Importing is adding
a reference to a class file or package so that you can access objects and properties defined by
external classes.
For more information on including and importing, see Chapter 4, "Using ActionScript," in
Flex 2 Developer's Guide.

Using ActionScript

27

Advertisement

Table of Contents
loading

Table of Contents