问题描述
我有一个组件库.它有一个如下所示的清单文件:
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>
我使用以下编译器设置通过 FlashBuilder 编译库:
I compile the library through FlashBuilder with these compiler settings:
当我在其他 FlashBuilder 项目中使用编译库时,一切都按预期工作.我得到代码完成,当我从代码完成中选择一个建议时,命名空间属性会自动添加到组件中,如下所示:
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>
但是: FlashBuilder 会自动创建前缀ns".例如,我想将此自定义为e".如何让 FlashBuilder 默认使用这个自定义前缀?
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?
我有两个原因:
- 'ns' 什么也没说:它只是说一个命名空间已被使用,而不是什么命名空间.
- 当我使用其他以library://ns"等网址开头的库时.FlashBuilder 可能会开始对前缀进行编号以解决冲突(ns、ns1、ns2 等),这会更加混乱.
- 'ns' doesn't say anything: it just says A namespace has been used, not what namespace.
- 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.
我还将一个 config.xml 传递给编译器,其中包含以下与命名空间相关的声明:
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>
推荐答案
这个用于工作:
在您的/src 文件夹中创建一个名为 design.xml
的文件:
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>
在您的/src 文件夹中创建一个名为 manifest.xml
的文件:
Create a file called manifest.xml
in your /src folder:
<componentPackage>
<component id="MyClass" class="com.mangofactory.framework.MyClassTag"/>
</componentPackage>
在构建属性中配置您的命名空间 URL 等:
Configure your Namespace URL, etc in the build properties:
这应该会导致 Flash Builder 提示如下:
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>
(注意类显示为MyClass
而不是MyClassTag
,命名空间显示为mangos
)
(Note that the class appears as MyClass
instead of MyClassTag
, and the namespace appears as mangos
)
然而,我只是尝试这样做,尽管该类已正确重命名,但命名空间显示为 ns
.我知道这曾经在 FB3.x 中有效,也许我忘记了一个步骤,或者 FB4.5 已经破坏了它.
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.
这篇关于如何让 FlashBuilder 使用自定义命名空间前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!