Follow Flex After Dark on Twitter

MXML Namespaces

If you want to use custom components (outside of the mx or flash packages), first you'll have to setup a namespace tell Flex where to find your custom controls. (Using custom controls in your MXML can be a little tricky at first.)

See the end of this document for some links to external information about Namespaces.

The Default Namespace

http://www.adobe.com/2006/mxml

An MXML document created by Flex Builder will automatically bind the mx namespace to the Flex Core Library.

Using Custom Namespaces

Example, setup a namespace referencing the package my.custom.controls:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
   xmlns:mycontrols="my.custom.controls.*"
>

The "xmlns:mycontrols" declares an XML namespace, "mycontrols".

You can now refer to your custom components in the MXML using the namespace.

<mycontrols:CustomComponent id="abc"
   ...
/>

The declaration of your (mycontrols:CustomComponent) element has the following parts:

  • mycontrols - The namespace you setup, tells Flex the package your components are in
  • CustomComponent - The name of the class/component in the package

Of course you can setup several package/namespace bindings in MXML.

Related Links:

Related Docs
Recent Docs
  • MXML Namespaces Overview of MXML Namespaces and how to use custom components in MXML.
  • MXML Component MXML Component
  • Flex Libraries A Library is collection of Flex/ActionScript classes and resources compiled to a .swc file.
  • Flex Remoting Flex Remoting and the RPC package provide robust, asynchronous communication with remote servers via HTTP and Web Services.
  • Flex Projects Overview of the different types of projects that can be created with Flex Builder.
Random Docs
  • Flex Form Validation Form Validation techniques and usage examples.
  • ActionScript AsyncToken Handling asynchronous requests and results with the AsyncToken class.
  • ActionScript ExternalInterface ActionScript's ExternalInterface class and IExternalInterface interface allow for two-way communication between ActionScript and browser JavaScript.
  • Flex Data Providers Several Flex components, including all list-based controls, display data from a data provider, a collection or object that contains the data displayed by the control.
  • Flex Text Controls Flex Text Controls allow the display and input of simple and rich HTML text.