What does different namespaces mean in Flex?

2019-07-16 23:51发布

问题:

I worked on a flex application 6-7 months back. We used flex 3.5 sdk. Now we are upgrading our flex app with flex sdk 4/4.1

I am still new to flex development and I have a very basic question related to namespace.

I have seen three different namespaces in flex sample applications. What is the purpose of having three diff namespaces? When do I use each of them ?

xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark" 
xmlns:mx="library://ns.adobe.com/flex/mx"

Thanks

回答1:

Namespaces are a way of logically grouping code together. Here's some more on that from Adobe.

In your particular example, these are XML Namespaces.

The particular namespaces listed above are listed as they are being used by your Flex application for:

fx - Contains the top-level ActionScript Language elements.

s - Include the Flex Spark components

mx - Contains all the components in the Flex mx.* packages, flex charting & data visualization components.

For more info on these particular namespaces and using XML namespaces in general: http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf5f39f-7ff7.html#WS2db454920e96a9e51e63e3d11c0bf5f39f-7ff3



回答2:

Also found out this document that explains upgrading flex app from sdk 3 to sdk 4. This pdf contains explanation of namespaces. http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/flex/pdfs/upgrading-flex3-to-flex4-techguide.pdf



回答3:

The mx namespace is the original namespace for Flex components. The s namespace points to the newer Spark components, many of which have the same class names (s:Application vs. mx:Application for example). I haven't used the fx namespace yet, but I'm fairly certain it is used for effect and transition declarations, which are done differently than mx effects. Hope that helps.