flex组件tree动态加载XML问题
我很纳闷,如果把xml直接放到代码里面的<fx:XMLList></fx:XMLList>,代码运行正常,然而通过HttpService或者URLLoader加载进来后,...
我很纳闷,如果把xml直接放到代码里面的<fx:XMLList></fx:XMLList>,代码运行正常,然而通过HttpService或者URLLoader加载进来后,就不能正常使用了,这是怎么回事儿?
<?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"
creationComplete="initApp()">
<fx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:HTTPService id="dataService"
url="../assets/fileSystem.xml"
result="resultHandler(event)" />
<fx:XML id="treeData" xmlns="">
<node label="nochump">
<node label="util">
<node label="zip">
<node label="CRC32.as "/>
<node label="Deflater.as "/>
<node label="Inflater.as "/>
<node label="ZipConstants.as "/>
<node label="ZipEntry.as "/>
<node label="ZipError.as "/>
<node label="ZipFile.as "/>
<node label="ZipOutput.as "/>
</node>
</node>
</node>
</fx:XML>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.collections.XMLListCollection;
[Bindable]
public var data:ArrayCollection = new ArrayCollection();
[Bindable]
public var xmlData:XMLListCollection = new XMLListCollection();
private function initApp():void
{
dataService.send();
//
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE,loadCompleteHandler);
loader.load(new URLRequest("../assets/fileSystem.xml"));
}
private function loadCompleteHandler(e:Event):void
{
xmlData = new XMLListCollection(new XMLList(e.currentTarget.data));
//treeData.node = new XML(e.currentTarget.data);
}
private function resultHandler(event:ResultEvent):void
{
//data = event.result.node;
}
]]>
</fx:Script>
<mx:Tree id="foldSystem" width="400" height="600"
labelField="@label" dataProvider="{treeData}" />
</s:Application> 展开
<?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"
creationComplete="initApp()">
<fx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:HTTPService id="dataService"
url="../assets/fileSystem.xml"
result="resultHandler(event)" />
<fx:XML id="treeData" xmlns="">
<node label="nochump">
<node label="util">
<node label="zip">
<node label="CRC32.as "/>
<node label="Deflater.as "/>
<node label="Inflater.as "/>
<node label="ZipConstants.as "/>
<node label="ZipEntry.as "/>
<node label="ZipError.as "/>
<node label="ZipFile.as "/>
<node label="ZipOutput.as "/>
</node>
</node>
</node>
</fx:XML>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.collections.XMLListCollection;
[Bindable]
public var data:ArrayCollection = new ArrayCollection();
[Bindable]
public var xmlData:XMLListCollection = new XMLListCollection();
private function initApp():void
{
dataService.send();
//
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE,loadCompleteHandler);
loader.load(new URLRequest("../assets/fileSystem.xml"));
}
private function loadCompleteHandler(e:Event):void
{
xmlData = new XMLListCollection(new XMLList(e.currentTarget.data));
//treeData.node = new XML(e.currentTarget.data);
}
private function resultHandler(event:ResultEvent):void
{
//data = event.result.node;
}
]]>
</fx:Script>
<mx:Tree id="foldSystem" width="400" height="600"
labelField="@label" dataProvider="{treeData}" />
</s:Application> 展开
2个回答
展开全部
请把具体的报错信息贴上来
这样光看程序没有人那么高深一眼就看出问题所在
去装一个debug版本的flash player
这样光看程序没有人那么高深一眼就看出问题所在
去装一个debug版本的flash player
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询