Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 20

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

Advertisement

The main application, or any other MXML component file, references the StateComboBox
component, as the following example shows:
<?xml version="1.0"?>
<!-- intro/MyApplication.mxml -->
<!-- Include the namespace definition for your custom components. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:MyComp="*">
<!-- Use the filename as the MXML tag name. -->
<MyComp:StateComboBox/>
</mx:Application>
The MXML tag name for a custom component is composed of two parts: the namespace
prefix, in this case
MyComp
for the file that implements the custom component. The tag name corresponds to the
filename of the component, in this case StateComboBox.mxml. Therefore, a file named
StateComboBox.mxml defines a component with the tag name of
<namespace:StateComboBox>
As part of the
<mx:Application>
namespace definition:
the same directory as the main application file, or in a directory included in the ActionScript
classpath. For more information on deploying MXML components, see
Simple MXML Components," on page
A best practice is to put your custom components in a subdirectory of your application. That
practice helps to ensure that you do not have duplicate component names because they have a
different namespace. If you stored your component in the myComponents subdirectory of
your application, you would specify the namespace definition as
xmlns:MyComp="myComponents.*"
20
Creating Flex Components
, and the tag name. The namespace prefix tells Flex where to look
.
tag, the main application file includes the following
. This definition specifies that the component is in
xmlns:MyComp="*"
77.
.
Chapter 7, "Creating

Advertisement

Table of Contents
loading

Table of Contents