Flex namespace usage

Source: Internet
Author: User

A friend in the official group of flex Step 1 asked me how to customize the namespace of my component in a way like xmlns: MX = "http://www.adobe.com/2006/mxml? Go to the compiler parameter in Adobe and find that you can use the-namespace and-include-namespaces parameters to specify your own URL.

First, we need to clarify the concept of manifest. xml.
Adobe is a kind of ActionScript 3.0 class library list. With the combination of manifest. xml and namespace, you can easily set your own namespace.

The following is a manifest. xml file: (Note: This file needs to be created by yourself and must be placed under the root directory of the Flex Library Project)
<? XML version = "1.0"?>
<Componentpackage>
<Component id = "testinga" class = "testinga"/>
</Componentpackage>
This XML file defines a class with ID = "testinga" (Note: If this class is in the package, you should also write the package address, for example: cn.org. kenshin. testinga)

Use the following parameters:
-Namespace http://www.k-zone.cn manifest. xml
-Namespace: declare a URI as the namespace of the http://www.k-zone.cn, and use manifest. XML as the current ActionScript 3.0 inventory file.
-Include-namespaces http://www.k-zone.cn
-Include-namespaces: Include the namespace of the http://www.k-zone.cn in the Library (SWC.

Of course, if the current compilation environment is Flex Builder (flash builder), the above content will become simpler.

Copy the Library to the Lib folder where you want to use it, and then use the following statement:
Xmlns: zone = "http://www.k-zone.cn"
Finally, see:

Now we have a question:NamespaceWhat is the difference between SWC generated in the way of manifest. xml and unspecified SWC? We can use the decompression software to open SWC and get the following two files:
Catalog. xml
Library.swf

The contents in catalog. XML are as follows:

<? XML version = "1.0" encoding = "UTF-8"?> <SWC xmlns = "http://www.adobe.com/flash/swccatalog/9"> <versions> <SWC version = "1.2"/> <flex version = "3.2.0" build = "3958"/> </versions> <features> <feature-script-deps/> <feature-components/> <feature-files/> </features> <Components> <Component classname = "testinga" name = "testinga" uri = "http://www.k-zone.cn"/> </Components> <libraries> <library path = "library.swf"> <script name = "testinga" Mod = "1244462205848" signaturechecksum = "3185651073"> <def id = "testinga" /> <Dep id = "object" type = "I"/> <Dep id = "as3" type = "N"/> </SCRIPT> <digests> <digest type = "SHA-256" signed = "false" value = "inline"/> </digests> </library> </libraries> <files> </Files> </SWC>
Please note that the red bold part is the one we previously specified. Namespace .

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.