How can I make FlashBuilder use a custom namespace prefix

大憨熊 提交于 2019-11-30 09:54:22

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:

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.

If you just change xmlns:ns to xmlns:e or xmlns:foo then the MXML parser will pick up on the change. It's not all that difficult to change, and I don't think there is a way to change how it generates namespaces by default.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!