flex中httpservice调用本工程的books.xml后显示不出结果,添加了<fx:declarations></fx:declarations>
是用send()连接的,程序如下:<?xmlversion="1.0"encoding="utf-8"?><s:Applicationxmlns:fx="http://n...
是用send()连接的,程序如下:
<?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" minWidth="955" minHeight="600" creationComplete="init()">
<fx:Script>
<![CDATA[
import mx.collections.*;
import mx.rpc.events.*;
public var books:ArrayCollection;
private function init():void
{
bookDataIn.send();
}
private function bookHandler(event:ResultEvent):void
{
books=event.result.books.stock;
}
]]>
</fx:Script>
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Declarations>
<s:HTTPService id="bookDataIn" url="ja/books.xml" result="bookHandler(event)" resultFormat="e4x">
</s:HTTPService>
</fx:Declarations>
</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" minWidth="955" minHeight="600" creationComplete="init()">
<fx:Script>
<![CDATA[
import mx.collections.*;
import mx.rpc.events.*;
public var books:ArrayCollection;
private function init():void
{
bookDataIn.send();
}
private function bookHandler(event:ResultEvent):void
{
books=event.result.books.stock;
}
]]>
</fx:Script>
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Declarations>
<s:HTTPService id="bookDataIn" url="ja/books.xml" result="bookHandler(event)" resultFormat="e4x">
</s:HTTPService>
</fx:Declarations>
</s:Application> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询