User Guide

120 Chapter 5: Working with Components
To specify component namespaces in your code:
Depending on the type and location of the component you want to insert, specify the
namespace as follows:
Standard Macromedia controls and containers If working with a standard Macromedia
control or container, you dont need to specify a namespace. The namespace for all
Macromedia components is http://www.macromedia.com/2003/mxml/ and is specified in the
<mx:Application> tag.
For example, if you want to insert a ComboBox control, which is a Macromedia component,
enter the ComboBox tag between the opening and closing
<mx:Application> tags, as follows:
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:ComboBox/>
</mx:Application>
You can omit the mx prefix from the component tag if you dont specify it in the xmlns
property name (you use
xmlns="..." instead of xmlns:mx="..."). The following example is
identical to the previous one, except that the prefix is omitted from the component tag:
<Application xmlns="http://www.macromedia.com/2003/mxml">
<ComboBox/>
<Application>
Custom MXML and ActionScript components
If you want to insert a custom MXML or
ActionScript component, the namespace is defined by the location of the component file in
the applications root folder on the server.
For example, if you write a custom MXML component called myButton.mxml and save it on
the Flex server in the assets/components/mycontrols subfolder in your application root folder,
enter the following namespace for the component:
xmlns:xyz="assets.components.mycontrols.*"
The property suffix :xyz tells you what tag prefix to use to reference the components in the
specified namespace. If the suffix is
:xyz, then use the xyz: tag prefix in your code to reference
a component in the namespace, as follows:
<xyz:myButton xmlns:xyz="assets.components.mycontrols.*" />
If the component file is located in the application root folder itself, the namespace is *
(asterisk), as follows:
... xmlns:xyz="*"
The namespace is also * (asterisk) if the component file is located in the /WEB-INF/flex/
user_classes subfolder in your applications root folder on the server. For example, if you place
the myButton.mxml component file in the /WEB-INF/flex/user_classes folder on the server,
enter the following tag to insert the component into an MXML file:
<xyz:myButton xmlns:xyz="*" />
Note: If two components have the same name and one is located in the application root folder and
the other is located in the WEB-INF folder, the component in the application root folder is used
first.