Google Groups Home
Help | Sign in
httpservice + asp 使用心得
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
leonjhon  
View profile
 More options Apr 6, 3:07 pm
From: leonjhon <zhaolice...@gmail.com>
Date: Sun, 6 Apr 2008 12:07:26 -0700 (PDT)
Local: Sun, Apr 6 2008 3:07 pm
Subject: httpservice + asp 使用心得
httpservice + asp 使用心得
折腾了一晚上,终于有点结果了,现在把我的简单代码贴上来,欢迎大家拍砖!
main.mxml代码如下:
?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
        <mx:Style>
                .mystyle{
                        font-family:宋体;
                        font-size:14px;
                }
        </mx:Style>
        <mx:Script source="testAsy.as">
        </mx:Script>
        <mx:HTTPService id="testHS" resultFormat="text"
result="bb(event);">
        </mx:HTTPService>
        <mx:Button click="sendAsy();" label="确定" x="141" y="198"
styleName="mystyle">
        </mx:Button>
        <mx:TextInput id="txt1" x="95" y="105"/>
        <mx:TextInput id="txt2" x="95" y="144"/>
        <mx:TextInput id="txtResult" text="结果显示区" x="50" y="228"
styleName="mystyle">
        </mx:TextInput>
        <mxabel x="52" y="107" text="用户名" styleName="mystyle"/>
        <mxabel x="52" y="146" text="密  码" styleName="mystyle"/>
</mx:Application>

testAsy.as 代码如下
// ActionScript file
import flash.net.URLVariables;
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
internal function sendAsy():void{ //异步发送 get 方式,带参数
        System.useCodePage=true;
        var url:String="postBack.asp";
        var username:String=txt1.text;
        var password:String=txt2.text;
        url=url+"?"+"username="+username;
        url=url + "&password="+password;
        testHS.url=url;
        testHS.method="GET";
        testHS.send();

}

internal function bb(evt:ResultEvent):void
{
        txtResult.text=evt.result.toString();

}

postBack.asp 代码如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
response.charset="utf-8"
a = "我写的测试我再试!"
b=request("username") & "|"
c=request("password") & "|"
response.write a & b & c
%>

运行说明,点击按钮即可异步获取数据,这里测试的是简单文本方式的,不过有个问题,每次修改完asp中的中文后,点击按钮,第一次显示乱码,再次点击就
正常了。

我的 msn:leonjho...@hotmail.com 欢迎大家与我交流,也欢迎高手多提宝贵意见。
Go to source web page: httpservice + asp 使用心得 - RIACHINA 中国RIA开发者论坛 -
Powered by Discuz!NT


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google