flex httpservice 接收xml 返回为空 是怎么回事?
username.xml文件如下<?xmlversion="1.0"encoding="UTF-8"?><user><userinfo><name>yyy</name><...
username.xml文件如下
<?xml version="1.0" encoding="UTF-8"?>
<user>
<userinfo>
<name>yyy</name>
<password>123</password>
</userinfo>
<userinfo>
<name>vv</name>
<password>123</password>
</userinfo>
</user>
======================================
LoginPanel.mxml文件如下
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
width="300" height="250"
fontSize="18"
title="请登录系统"
borderColor="#2A2A2A"
backgroundColor="#828282"
backgroundAlpha="0.7"
styleName="WidgetText">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
[Bindable]
private var list:ArrayCollection=new ArrayCollection();
private function getData(event:ResultEvent):void{
list = event.result.user.userinfo;
}
private function LoginUser():void
{
Alert.show("---"+list.length);
for (var i:Number = 0; i < list.length; i++)
{
// if(username.text == list.name && Password.text == list.password )
// {
// PopUpManager.removePopUp(this);
// }
// else
// {
// Msg.text="请检查用户名和密码";
// }
}
}
]]>
</mx:Script>
<!--//读取XML表里的用户数据-->
<mx:XML id="test" source="com/esri/solutions/flexviewer/username.xml"/>
<mx:HTTPService id="booksXML" url="com/esri/solutions/flexviewer/username.xml"
showBusyCursor="true" result="getData(event);"/>
<mx:Label text="姓名:" fontSize="16" x="10" y="31"/>
<mx:Label text="密码:" fontSize="16" x="10" y="80"/>
<mx:Label id="Msg" text="" fontSize="16" x="74" y="115"/>
<mx:TextInput id="username" x="74" y="26" />
<mx:TextInput id="Password" x="74" y="75" displayAsPassword="true"/>
<mx:Button label="登录" x="170" y="145" click="LoginUser();"/>
<mx:DataGrid id="booksGrid" width="1" height="1" visible="false"
dataProvider="{list}" creationComplete="this.booksXML.send()" >
<mx:columns>
<mx:DataGridColumn headerText="用户名称" dataField="name"/>
<mx:DataGridColumn headerText="用户密码" dataField="password" width="80"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
======================
getData(event)这个方法中为什么list是空的呢?
谢谢大家赐教了
怎么没人回答呀 展开
<?xml version="1.0" encoding="UTF-8"?>
<user>
<userinfo>
<name>yyy</name>
<password>123</password>
</userinfo>
<userinfo>
<name>vv</name>
<password>123</password>
</userinfo>
</user>
======================================
LoginPanel.mxml文件如下
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
width="300" height="250"
fontSize="18"
title="请登录系统"
borderColor="#2A2A2A"
backgroundColor="#828282"
backgroundAlpha="0.7"
styleName="WidgetText">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
[Bindable]
private var list:ArrayCollection=new ArrayCollection();
private function getData(event:ResultEvent):void{
list = event.result.user.userinfo;
}
private function LoginUser():void
{
Alert.show("---"+list.length);
for (var i:Number = 0; i < list.length; i++)
{
// if(username.text == list.name && Password.text == list.password )
// {
// PopUpManager.removePopUp(this);
// }
// else
// {
// Msg.text="请检查用户名和密码";
// }
}
}
]]>
</mx:Script>
<!--//读取XML表里的用户数据-->
<mx:XML id="test" source="com/esri/solutions/flexviewer/username.xml"/>
<mx:HTTPService id="booksXML" url="com/esri/solutions/flexviewer/username.xml"
showBusyCursor="true" result="getData(event);"/>
<mx:Label text="姓名:" fontSize="16" x="10" y="31"/>
<mx:Label text="密码:" fontSize="16" x="10" y="80"/>
<mx:Label id="Msg" text="" fontSize="16" x="74" y="115"/>
<mx:TextInput id="username" x="74" y="26" />
<mx:TextInput id="Password" x="74" y="75" displayAsPassword="true"/>
<mx:Button label="登录" x="170" y="145" click="LoginUser();"/>
<mx:DataGrid id="booksGrid" width="1" height="1" visible="false"
dataProvider="{list}" creationComplete="this.booksXML.send()" >
<mx:columns>
<mx:DataGridColumn headerText="用户名称" dataField="name"/>
<mx:DataGridColumn headerText="用户密码" dataField="password" width="80"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
======================
getData(event)这个方法中为什么list是空的呢?
谢谢大家赐教了
怎么没人回答呀 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询