Flex:ArrayCollection转xml形式的实例
ArrayCollection转成xml类型示例
下面模拟一组数据exams,将其转化为xml形式.详细代码见下:
Xml代码
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" fontSize="12" creationComplete="init()">
<mx:Style source="style/Smoke.css"/>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]private var shijxml:XML;
private function init():void{
shijxml = arrToXml(exams);
}
[Bindable]
public var exams:ArrayCollection = new ArrayCollection(
[{sjtitle:"数据结构第一章", kemu:"数据结构",shijID:"sj000" ,num:"30"},
{sjtitle:"数据结构第二章", kemu:"数据结构",shijID:"sj001" ,num:"30"},
{sjtitle:"组成原理第一章", kemu:"组成原理",shijID:"zc000" ,num:"50"}, &nb
相关文档:
<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate the DateTimeAxis class. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
import mx.collections.ArrayCollection;
......
(1)tree点击事件public function handleList(ev:ResultEvent)
{
sourceList=ev.result as ArrayCollection;
}
private function tree_itemClick(evt:ListEvent):void {
var item:Object = Tree(evt.currentTarget).selectedItem;
if (pmtree.dataDescriptor.isBranch(item)) {
......
1、自定义组件
2、自定义事件
3、结合使用
一、自定义组件(使用的是Flex组件,ActionScript组件相对麻烦点,可视化差点)
该组件由一个TextArea和两个Button组成,如图:
代码:
MyComponent.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width=" ......