6. 数据交互与通信
Data
Collection
private var nameArray:Array = ["jex", "kenny", "richard"];
//或者 private var nameArrayCollection:ArrayCollection = new ArrayCollection(nameArray);
private var nameArrayCollection:ArrayCollection = new ArrayCollection();
nameArrayCollection.source = nameArray;
7. 数据交互与通信
XML private var personXML:XML =
<root>
<person>
<firstName>jex</firstName>
<lastName>chan</lastName>
</person>
<person>
<firstName>kenny</firstName>
<lastName>yang</lastName>
</person>
<person>
<firstName>hafid</firstName>
<lastName>tang</lastName>
</person>
</root>;
xmlListCollection = new XMLListCollection(personXML.person);
8. 数据交互与通信
XML
Array ArrayCollection
XMLList XMLListCollection
区别何在?
11. 数据交互与通信
XML
var xml:XMLList = dataXML.product;
trace(xml.toXMLString();
以XMLList方式列出所有Production的信息
12. 数据交互与通信
XML
var xml:XMLList = dataXML.product.(@name == "苹果MC700CH");
var xml:XMLList = dataXML.product.(attribute("name")=="苹果MC700CH");
得到name为“苹果MC700CH”这条Product
13. 数据交互与通信
XML
var xml:XMLList = dataXML.product.(quatity == 50);
得到quatity为50的Product信息
var xml:XMLList = dataXML.product.(@id == "001" || quatity == 45);
得到id为001或quatity为50的Product信息
14. 数据交互与通信
XML
//等价于:var xml:XMLList = dataXML.product.price;
var xml:XMLList = dataXML..price;
获取所有产物的price