package ProdcutVo { public class Haha { public function Haha() { } public var productname:String; public var image:String; public var remark:String; } } <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="1192" height="810" creationComplete="init();" > <mx:Script> <!--[CDATA[ import ProdcutVo.Haha; import mx.collections.IGroupingCollection; import mx.messaging.Producer; import mx.collections.ArrayCollection; import mx.events.ListEvent; import mx.rpc.events.ResultEvent; import mx.controls.Alert; import ProdcutVo.Product; [Bindable] private var list:ArrayCollection; private function init():void { var so:SharedObject = SharedObject.getLocal("validate","/"); var valid:Boolean = so.data.validateResult; if( valid != true ) { so.clear(); } else { var number:String = so.data.id.toString(); Alert.show(number,'para'); so.clear(); } } private function onclick():void { this.service.gettable.send(); } private function hello():void { this.service.HelloWorld(); } private function onResult(event:ResultEvent):void { Alert.show(event.result.toString()); } private function Result(event:ResultEvent):void { Alert.show(event.result.toString()); } private function datagridonclick(event:ListEvent):void { Alert.show(event.itemRenderer.data.label,event.type); } [Bindable] private var plist:ArrayCollection; private function getlist(event:ResultEvent):void { list=event.result as ArrayCollection; // dg.dataProvider=list; plist=new ArrayCollection(); for(var i:Number=0;i<list.length;i++ ) { var pd:Haha=new Haha(); pd.image=list[i].Image.toString(); pd.productname=list[i].Productname.toString(); pd.remark=list[i].Remark.toString(); plist.addItem(pd); } dg.dataProvider=plist; pname.text=list[0].Productname; img.source=list[0].Image; remark.text=list[0].Remark; pname0.text=list[1].Productname; img0.source=list[1].Image; remark0.text=list[1].Remark; pname1.text=list[2].Productname; img1.source=list[2].Image; remark1.text=list[2].Remark; pname2.text=list[3].Productname; img2.source=list[3].Image; remark2.text=list[3].Remark; pname3.text=list[4].Productname; img3.source=list[4].Image; remark3.text=list[4].Remark; } [Bindable] private var ulist:ArrayCollection; private function getuser(event:ResultEvent):void { ulist=new ArrayCollection(); ulist=event.result as ArrayCollection; if(ulist==null) { Alert.show('用户名密码错误','error'); return; } Alert.show('登陆成功','sussce'); } private function ongetusers():void { this.service.getUser.send(); } ]]--> </mx:Script> <mx:WebService id="service" wsdl="http://192.168.1.95/MyflexService/Service.asmx?wsdl" useProxy="false" fault="Alert.show('通讯失败,请检查服务器是否存在','提示')"> <mx:operation name="gettable" result="getlist(event)" > </mx:operation> <mx:operation name="HelloWorld" result="onResult(event)"> </mx:operation> <mx:operation name="getUser" result="getuser(event)" > <mx:request> <uname>{this.txtuname.text}</uname> <password>{this.txtpass.text}</password> </mx:request> </mx:operation> </mx:WebService> <mx:DataGrid id="dg" x="38" y="299" width="650" height="491" fontSize="15" itemClick="datagridonclick(event)" > <mx:columns> <mx:DataGridColumn headerText="CompanyName" dataField="productname" /> <mx:DataGridColumn headerText="Remark" dataField="remark"/> <mx:DataGridColumn headerText="HomePage" dataField="image" itemRenderer="mx.controls.Image"> </mx:DataGridColumn> </mx:columns> </mx:DataGrid> <mx:Button x="38" y="25" label="Button" click="onclick()"/> <mx:Button x="170" y="25" label="Button" click="hello()"/> <mx:Panel x="38" y="55" width="650" height="220" layout="absolute"> <mx:Image x="26" y="10" width="92" height="68" id="img"/> <mx:Label x="26" y="106" id="pname" fontSize="15"/> <mx:Label x="26" y="151" id="remark" fontSize="15"/> <mx:Image x="151" y="10" width="92" height="68" id="img0"/> <mx:Label x="151" y="106" id="pname0" fontSize="15"/> <mx:Label x="151" y="151" id="remark0" fontSize="15"/> <mx:Image x="278" y="10" width="92" height="68" id="img1"/> <mx:Label x="278" y="106" id="pname1" fontSize="15"/> <mx:Label x="278" y="151" id="remark1" fontSize="15"/> <mx:Image x="404" y="10" width="92" height="68" id="img2"/> <mx:Label x="404" y="106" id="pname2" fontSize="15"/> <mx:Label x="404" y="151" id="remark2" fontSize="15"/> <mx:Image x="528" y="10" width="92" height="68" id="img3"/> <mx:Label x="528" y="106" id="pname3" fontSize="15"/> <mx:Label x="528" y="151" id="remark3" fontSize="15"/> </mx:Panel> <mx:Label x="739" y="55" text="用户名:" fontSize="12"/> <mx:TextInput id="txtuname" x="823" y="55"/> <mx:Label x="739" y="117" text="密码:" fontSize="12"/> <mx:TextInput id="txtpass" x="823" y="117"/> <mx:Button x="740" y="179" label="登陆" fontSize="12" click="ongetusers();"/> </mx:Application>
[错误报告] [收藏] [打印] [关闭] [返回顶部]
CopyRight 2009 www.allniu.com版权所有