先看看Flex如何调用WebService。代码如下,调用的还是手机号码归属地查询,两个参数,一个手机号码,一个用户Id。
- <mx:WebService?id="WS"?wsdl="http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl"? ?
-
?fault="Alert.show(event.fault.faultString),?'Error'"?>?
-
????????<mx:operation?name="getMobileCodeInfo"?resultFormat="object"??result="GetCourse(event)">?
-
????????????<mx:request>?
-
????????????????<mobileCode>{txtMobileNumber.text}</mobileCode>?
-
????????????????<userID>{txtUserId.text}</userID>?
-
????????????</mx:request>?
-
????????</mx:operation>?
-
</mx:WebService>?
看看as是怎么写的,代码如下
- function?GetCourse(event:ResultEvent) ?
- ????????????{ ?
-
????????????????var?result:XML=new?XML(event.result.toString()); ?
-
????????????????if(result.Error!=null&&result.Error!="") ?
- ????????????????{ ?
- ????????????????????labInfo.text=result; ?
- ????????????????} ?
-
????????????????else{ ?
-
????????????????????labInfo.text="调用失败!"; ?
- ????????????????} ?
- ????????????}?
然后在某个按钮下写个click事件,<mx:Button x="137" y="67" label="调用WebService方法" click="showMsg();" width="141"/>对应的as代码如下
- function?showMsg() ?
- ????????{ ?
-
?????????????WS.getMobileCodeInfo(); ?
- ????????}?
看看运行效果,如下图

怎么样很简答吧。最后再看看如何弹出一个modal页面。
- <mx:TitleWindow?x="241"?y="163"?width="539"?height="260"?id="titleWindow"??layout="absolute"?title="学生信息详细信息"?visible="false">?
-
?????????????<mx:Button?x="452"?y="196"?label="关闭"?width="57"?click="closeHandler();"/>?
-
?????????????<mx:RichTextEditor?x="10"?y="10"?title="Title"?height="180"?width="499">?
-
?????????????</mx:RichTextEditor>?
-
?????</mx:TitleWindow>?
as代码如下
- import?mx.managers.PopUpManager; ?
-
private?function?closeHandler():?void{????????????? ?
- ??????????????????PopUpManager.removePopUp(titleWindow);??? ?
-
??????????????????titleWindow.visible=false; ?
- ?????????????} ?
- ?????????????function?showPop() ?
- ?????????????{ ?
-
????????????????titleWindow.visible=true;?? ?
-
????????????????PopUpManager.addPopUp(titleWindow,this,true);?? ?
- ?????????????}?
运行效果如下

今天就写这些,祝大家龙年愉快。