我如何使FlashBuilder使用自定义命名空间前缀 [英] How can I make FlashBuilder use a custom namespace prefix
问题描述
<?xml version =1.0?>
< componentPackage>
< component id =AutoCompleteclass =be.edge.components.AutoComplete/>
<! - 为了简洁,省略了更多的组件 - >
< / componentPackage>
我使用这些编译器设置通过FlashBuilder编译库:
当我在其他FlashBuilder项目中使用编译的库时,一切都按预期工作。我得到代码完成,当我从代码完成中选择一个建议时,一个名称空间属性会自动添加到组件中,如下所示:
< 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默认使用这个自定义前缀?
我有两个原因:
- 'ns'没有说什么:它只是说名称空间已被使用,而不是名称空间。类库也是以library:// ns开始的,FlashBuilder可能会开始对前缀进行编号以解决冲突(ns,ns1,ns2等),这会更加令人困惑。 b $ b
编辑:
我也传递一个config.xml到具有以下与名称空间相关的声明的编译器:
< compiler>
<命名空间>
< namespace>
< uri> library://ns.edge.be< / uri>
< manifest> manifest.xml< / manifest>
< / namespace>
< /命名空间>
< / compiler>
< include-namespaces>
< uri> library://ns.edge.be< / uri>
< / include-namespaces>
解决方案使用 :
$ b 在/ src文件夹中创建一个名为 design.xml
的文件: <?xml version =1.0?>
< design>
<命名空间>
< namespace prefix =mangosuri =http://com.mangofactory.sample/mxml/2010/>
< /命名空间>
< / design>
创建一个名为 manifest.xml
的文件你的/ src文件夹:
< componentPackage>
< component id =MyClassclass =com.mangofactory.framework.MyClassTag/>
< / componentPackage>
在构建属性中配置Namespace URL等:
这是假设 导致Flash Builder会提示如下:
<?xml version =1.0encoding =utf-8?> ;
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:声明>
< mangos:MyClass />
< / fx:声明>
< / s:Application> (请注意,该类显示为 MyClass
而不是 MyClassTag
,命名空间显示为 mangos
)
<但是,我只是尝试这样做,虽然类正确地重命名,名称空间显示为 ns
。我知道这个曾经在FB3.x中工作,也许我已经忘记了一个步骤,或者FB4.5打破了它。
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:
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:
- '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.
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>
解决方案 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.
这篇关于我如何使FlashBuilder使用自定义命名空间前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!