Dom*_*oSL 2 flash post actionscript-3
我想在用户点击动画片段时在同一个标签页上打开一个网页.我正在使用这种方法:
var url:String = "http://www.google.com";
var request:URLRequest = new URLRequest(url);
try {
navigateToURL(request);
} catch (e:Error) {
trace("Error occurred!");
}
Run Code Online (Sandbox Code Playgroud)
但我不知道如何打开它发送POST变量.那可能吗?
Lar*_*sjö 10
是的,可以通过在URLRequest上指定POST作为方法,并使用flash.net.URLVariables作为变量.这是文档中的示例:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLRequest.html
package {
import flash.display.Sprite;
import flash.net.navigateToURL;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLVariables;
public class URLRequest_method extends Sprite {
public function URLRequest_method() {
var url:String = "http://www.[yourDomain].com/application.jsp";
var request:URLRequest = new URLRequest(url);
var variables:URLVariables = new URLVariables();
variables.exampleSessionId = new Date().getTime();
variables.exampleUserLabel = "guest";
request.data = variables;
request.method = URLRequestMethod.POST;
navigateToURL(request);
}
}
}
Run Code Online (Sandbox Code Playgroud)