Question

Given a flex application or module, you can specify a custom xml namespace as follows:

<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:custom="custom.namespace.*">

We can then refer to mxml components in the directory custom/namespace/ using the custom tag. For example, if I have the components Custom1 and Custom2 in the custom/namespace directory, I can refer to them like so:

<custom:Custom1/>
<custom:Custom2/>

Is there a way to map multiple directories onto the same tag? That is, if I have components in a subdirectory of custom/namespace, like custom/namespace/sub with component SubCustom1, is there a way to modify the flex document so the custom tag can refer to SubCustom1?

Note that one workaround I found was to add a new tag for each directory (e.g. xmlns:custom.sub="custom.namespace.sub.*", and then:

<custom.sub:SubCustom1>

This solution seems like a kludge, though.

Was it helpful?

Solution

To create a custom namespace in flex you need to

1) Create a custom manifest file: e.g.

<?xml version="1.0" encoding="utf-8" ?>
<componentPackage>

    <component id="Accordion" class="mx.containers.Accordion"/>
    ....

2) Add something similar to the following to your flex-compiler.xml file:

<compiler>
    ...
      <namespaces>
         <!-- Specify a URI to associate with a manifest of components for use as MXML -->
         <!-- elements.                                                                -->
         <namespace>
            <uri>http://mycustomnamespace.com</uri>
            <manifest>custom-manifest.xml</manifest>
         </namespace>
      </namespaces>
</compiler>

You can read a more detailed explanation here.

This question was also answered here.

OTHER TIPS

The naming follows directly from the XML specification for namespaces. If you want to change custom to refer to the subdirectory change the namespace declaration:

xmlns:custom="custom.namespace.*"

to

xmlns:custom="custom.namespace.sub.*"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top