Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make FlashBuilder use a custom namespace prefix

I have a component library. It has a manifest file that looks like this:

<?xml version="1.0"?>
<componentPackage>
    <component id="AutoComplete" class="be.edge.components.AutoComplete" />
    <!-- more components left out for brevity -->
</componentPackage>

I compile the library through FlashBuilder with these compiler settings:

FlashBuilder library compiler namespace inputs

When I use the compiled library in other FlashBuilder projects everything works as expected. I get code completion and when I select a suggestion from the code completion a namespace attribute is automatically added to the component, like this:

<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" 
        xmlns:ns="library://ns.edge.be" >

    <ns:AutoComplete />

</s:Skin>

But: FlashBuilder automatically creates the prefix 'ns'. I would like to customize this to 'e' for instance. How can I make FlashBuilder use this custom prefix by default?

I have two reasons for this:

  1. 'ns' doesn't say anything: it just says A namespace has been used, not what namespace.
  2. when I use other libraries that also start with a url like 'library://ns.' FlashBuilder will probably start numbering the prefixes to resolve the conflict (ns, ns1, ns2, etc.), which would be even more confusing.

EDIT:

I also pass a config.xml to the compiler that has the following declarations relating to namespaces:

<compiler>
    <namespaces>
        <namespace>
            <uri>library://ns.edge.be</uri>
            <manifest>manifest.xml</manifest>
        </namespace>
    </namespaces>
</compiler>

<include-namespaces>
    <uri>library://ns.edge.be</uri>
</include-namespaces>
like image 266
RIAstar Avatar asked Jun 23 '11 12:06

RIAstar


1 Answers

This used to work:

Create a file called design.xml in your /src folder:

<?xml version="1.0" ?>
<design>
    <namespaces>
        <namespace prefix="mangos" uri="http://com.mangofactory.sample/mxml/2010" />
    </namespaces>
</design>

Create a file called manifest.xml in your /src folder:

<componentPackage>
        <component id="MyClass" class="com.mangofactory.framework.MyClassTag"/>
</componentPackage>

Configure your Namespace URL, etc in the build properties: enter image description here

This is supposed to cause flash builder to prompt as follows:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx"
               xmlns:mangos="http://com.mangofactory.sample/mxml/2010">
    <fx:Declarations>
        <mangos:MyClass />
    </fx:Declarations>
</s:Application>

(Note that the class appears as MyClass instead of MyClassTag, and the namespace appears as mangos)

However, I just tried doing this, and although the class was renamed correctly, the namespace appeared up as ns. I know this used to work in FB3.x, maybe I've either forgotten a step, or FB4.5 has broken it.

like image 77
Marty Pitt Avatar answered Oct 23 '22 15:10

Marty Pitt