Understanding namespaces flex理解命名空间
示例:ex5_08_solution
?
<?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" width="980" height="690" xmlns:components="components.*" skinClass="skins.ApplicationContainerSkin">?
1.MXML本质上是一个xml文件,所以它的第一行是
<?xml version="1.0" encoding="utf-8"?>??
2.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:s="library://ns.adobe.com/flex/spark"?
xmlns:mx="library://ns.adobe.com/flex/mx"
这三个URI只是一个名字,它对应的xml文件要从flex-config找(D:\Program Files\Adobe\Adobe Flash Builder 4\sdks\4.1.0\frameworks)
<namespaces> <!-- Specify a URI to associate with a manifest of components for use as MXML --> <!-- elements. --> <namespace> <uri>http://ns.adobe.com/mxml/2009</uri> <manifest>mxml-2009-manifest.xml</manifest> </namespace> <namespace> <uri>library://ns.adobe.com/flex/spark</uri> <manifest>spark-manifest.xml</manifest> </namespace> <namespace> <uri>library://ns.adobe.com/flex/mx</uri> <manifest>mx-manifest.xml</manifest> </namespace> <namespace> <uri>http://www.adobe.com/2006/mxml</uri> <manifest>mxml-manifest.xml</manifest> </namespace> </namespaces>?
?
看下这三个库的作用
mx命名空间引用flex3的类,包括mx包和数据可视化组件
?
fx命名空间对flex4来说是新的,包括诸如对象,数据,布尔和阵列的顶层ActionScript语言元素
还包括诸如脚本,声明和样式的内建编译器标签
?
s或Spark命名空间包含flex4可用的所有新的spark组件和文本框架类
还可以为网络服务,http服务和来自spark命名空间的远程对象请求引用数据服务组件
?
另外xmlns:components="components.*"?? 用来指明自己定义的components
自定义组件的使用:
<components:EmployeePortalPanel title="Monthly Events" panelTitleColor="#0D86B8"> <components:MonthlyEvents/> </components:EmployeePortalPanel>?
例子中的<components:MonthlyEvents/> 就是一个自定义组件,名字与mxml的名字相同
spark.effects.AddAction?(as文件)
内容如下----------------as和mxml的关系就像java与jsp.
package spark.effects { import flash.display.DisplayObjectContainer; import mx.core.IVisualElement; import mx.core.IVisualElementContainer; import mx.core.mx_internal; import spark.effects.supportClasses.AddActionInstance; import mx.effects.IEffectInstance; import mx.effects.Effect; import mx.effects.effectClasses.PropertyChanges; use namespace mx_internal; //-------------------------------------- // Excluded APIs //-------------------------------------- [Exclude(name="duration", kind="property")] public class AddAction extends Effect { include "../core/Version.as";?