|
1#
大 中
小 发表于 2008-5-26 20:55
mxml内容 引用:<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" fontSize="12" creationComplete="initApp()">
<mx:HTTPService id="PostService" url="http://192.168.1.126:8080/3/bar/demo.jsp" useProxy="false" method="POST" result="showResult(event)" >
<mx:request xmlns="">
<username>{username.text}</username>
</mx:request>
</mx:HTTPService>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.*;
import mx.controls.Alert;
import mx.events.*;
[Bindable]
public var TmpData:Array;
[Bindable]
public var Data:ArrayCollection;
private function initApp():void
{
PostService.send();
Data = new ArrayCollection();
}
private function showResult(event:ResultEvent):void{
//Alert.show(e.result as XML);
TmpData=event.result.phonelist.phone.source as Array;
Data.source=TmpData.slice(0, TmpData.length);
}
]]>
</mx:Script>
<mx:Panel x="45" y="102" width="230" height="348" layout="absolute" title="订单信息" fontSize="12">
<mx:Label x="19" y="19" text="姓名"/>
<mx:TextInput x="74" y="17" width="117" id="username"/>
<mx:TextInput x="74" y="100" width="117" id="useremail"/>
<mx:Label x="19" y="102" text="邮箱"/>
<mx:TextInput x="74" y="57" width="117" id="usertel"/>
<mx:Label x="19" y="59" text="电话"/>
<mx:TextInput x="75" y="182" width="117" id="ordernum"/>
<mx:Label x="10" y="186" text="预定数量"/>
<mx:Label x="10" y="145" text="产品名称"/>
<mx:TextInput x="74" y="141" width="117" id="productname"/>
<mx:Label x="10" y="225" text="期望成交时间"/>
<mx ateField x="98" y="221" id="buytime"/>
<mx:Button x="67" y="267" label="提交订单" id="txtSubmit" click="PostService.send()" />
</mx:Panel>
<mx ataGrid x="302" y="176" width="422" height="172" id="showList" dataProvider="{Data}">
<mx:columns>
<mx ataGridColumn headerText="姓名" dataField="username" />
<mx:DataGridColumn headerText="邮箱" dataField="col2"/>
<mx:DataGridColumn headerText="电话" dataField="col3"/>
<mx:DataGridColumn headerText="预定数量" dataField="col4"/>
<mx:DataGridColumn headerText="期望成交时间" dataField="col5"/>
</mx:columns>
</mx:DataGrid>
</mx:Application> jsp内容 引用:<?xml version="1.0" encoding="gb2312"?>
<phonelist>
<phone id="111" username="dd">
</phone>
</phonelist> 已经成功读取了 http://192.168.1.126:8080/3/bar/demo.jsp文件中的xml各个节点属性值,可是在返回值的时候 TmpData总是为null
报错提示“ TypeError: Error #1009: 无法访问空对象引用的属性或方法”
各位高手帮忙看看,谢谢!
[ 本帖最后由 lkp528 于 2008-5-26 20:58 编辑 ]
When the door to happiness
|