Flex与.NET交互

方法一:

把Flex生成的SWF文件(在目录../history/xx.swf)中,考到.NET项目(WEB)中,然后在页面上引用就可以了。如

<body style="margin:0px;" mce_style="margin:0px;"> <form id="form1" runat="server"> <div> <embed src="FlexNet.swf" mce_src="FlexNet.swf" width="100%" height="100%" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always"></embed> </div> </form> </body>

方法二:

调用.NET页面。示例如下:

在Flex文件中:

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" textAlign="center" width="100%" height="100%"> <mx:HTTPService showBusyCursor="true" id="getuser" result="getuserproc();" url="http://localhost:54062/FLEX/Default.aspx"> <mx:request> <username> {this.txtUserName.text} </username> <userpassword> {this.txtUserPassWord.text} </userpassword> </mx:request> </mx:HTTPService> <mx:Script> <!--[CDATA[ import mx.controls.Alert; import mx.rpc.AbstractOperation; public function getuserproc():void { var returnValue:String=getuser.lastResult.Result.user; switch(returnValue) { case "ok": Alert.show("您成功的登录了","提示信息",Alert.OK,this,null,null,Alert.YES); break; case "pwderror": Alert.show("密码错误,登录失败","提示信息",Alert.OK,this,null,null,Alert.YES); break; case "uiderror": Alert.show("无此用户名,登录失败","提示信息",Alert.OK,this,null,null,Alert.YES); break; } } ]]--> </mx:Script> <mx:Panel id="UserRegPanel" x="9.15" y="9.05" title="用户登录" width="302" height="204" layout="absolute" textAlign="left"> <mx:Label x="10" y="22" text="用户名:" id="lblUserName" enabled="true" fontSize="15"/> <mx:Label x="10" y="64" text="密 码:" id="lblUserPassWord" enabled="true" fontSize="15"/> <mx:TextInput x="83" y="22" fontSize="15" id="txtUserName"/> <mx:TextInput x="83" y="63" fontSize="15" id="txtUserPassWord" displayAsPassword="true"/> <mx:Button x="96.45" y="108" label="登录" width="89" height="36" fontSize="15" enabled="true" click="getuser.send()"> </mx:Button> </mx:Panel> </mx:Application>

Default.aspx.cs:

protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["username"] != null && Request.QueryString["userpassword"] != null) { if (Request.QueryString["username"].Equals("drj") && Request.QueryString["userpassword"].Equals("123")) { Response.Write("<Result><user>ok</user></Result>"); Response.Flush(); } else if (!Request.QueryString["username"].Equals("drj")) { Response.Write("<Result><user>uiderror</user></Result>"); Response.Flush(); } else if (!Request.QueryString["userpassword"].Equals("123")) { Response.Write("<Result><user>pwderror</user></Result>"); Response.Flush(); } } }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值