在url参数中发送数组

时间:2014-11-03 20:44:35

标签: actionscript-3

如何编写AS以显示在所有文本字段中输入的确切信息,甚至显示' @'在url参数上。

enter image description here

我测试了表单,输出看起来像这样 -

电子邮件= cluneborg%40hotmail%2Ecom&安培; L-NAME = Luneborg&安培;拉链= 75052&安培; FNAME = Chistian

看起来应该是这样的 - email=cluneborg@hotmail.com& L-NAME = Luneborg&安培;拉链= 75052&安培; FNAME = Chistian

import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.net.navigateToURL;

mcButton.addEventListener(MouseEvent.MOUSE_UP, onClick);
function onClick(e:MouseEvent):void {
var scriptRequest:URLRequest = new URLRequest("../index.aspx");
var scriptLoader:URLLoader = new URLLoader();
var scriptVars:URLVariables = new URLVariables();

scriptLoader.addEventListener(Event.COMPLETE, handleLoadSuccessful);
scriptLoader.addEventListener(IOErrorEvent.IO_ERROR, handleLoadError);

scriptVars.fname = fname_txt.text;
scriptVars.lname = lname_txt.text;
scriptVars.email = email_txt.text;
scriptVars.zip = zip_txt.text;

scriptRequest.method = URLRequestMethod.POST;
scriptRequest.data = scriptVars;

scriptLoader.load(scriptRequest);

function handleLoadSuccessful($evt:Event):void
{
    trace("Message sent.");
}

function handleLoadError($evt:IOErrorEvent):void
{
    trace(scriptVars);
}

fname_txt.text = "";
lname_txt.text = "";
email_txt.text = "";
zip_txt.text = "";

}

mcButton.addEventListener(MouseEvent.ROLL_OVER, overFunction);
mcButton.addEventListener(MouseEvent.ROLL_OUT, outFunction);

function overFunction(evt:MouseEvent):void {
    //trace ('its working');
    mcView.gotoAndStop(2);
}
function outFunction(evt:MouseEvent):void {
    //trace ('its working');
    mcView.gotoAndStop(1);
}

fname_txt.addEventListener(FocusEvent.FOCUS_IN, clearBox1);
function clearBox1(FocusEvent)
   {
    fname_txt.text="";
   }

lname_txt.addEventListener(FocusEvent.FOCUS_IN, clearBox2);
function clearBox2(FocusEvent)
   {
    lname_txt.text="";
   }

email_txt.addEventListener(FocusEvent.FOCUS_IN, clearBox3);
function clearBox3(FocusEvent)
   {
    email_txt.text="";
   }

zip_txt.addEventListener(FocusEvent.FOCUS_IN, clearBox4);
function clearBox4(FocusEvent)
   {
    zip_txt.text="";
   }

不要担心ASP - 还没有建成。我想先测试输出。

1 个答案:

答案 0 :(得分:1)

试试这个:

var str:String = 'email=your_email%40hotmail%2Ecom&lname=your_name&zip=111111&fname=your_fist_name'
trace(unescape(str))  
// gives : email=your_email@hotmail.com&lname=your_name&zip=111111&fname=your_fist_name