本文介绍了AS3 URL 字符串 ->网址请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用一些不接受 products.php?cat=10
作为目标的加载器,因为它太愚蠢了,无法弄清楚文件名和查询字符串是什么.是否有 AS3 函数可以解析 URL 并根据查询字符串中的变量返回 URLRequest?
I'm using some loader that doesn't accept products.php?cat=10
as a target because it's too stupid to figure out what's the file name and what's the query string. Is there an AS3 function that will parse an URL and return a URLRequest based on variables in the query string?
推荐答案
有可能创建你需要的一切:
There is possibility to create all you need:
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.net.URLVariables;
import flash.net.URLRequestMethod;
import flash.events.Event;
// the path to the backend file
var url : String = 'http://youdomain.com/filepath.php';
// url variables all which will appear after ? sign
var urlVariables : URLVariables = new URLVariables ();
urlVariables['varname'] = 'varvalue';
urlVariables['varname1'] = 'varvalue1';
// here you can add as much as you need
// creating new URL Request
// setting the url
var request : URLRequest = new URLRequest ( url );
// setting the variables it need to cary
request.data = urlVariables;
// setting method of delivering variables ( POST or GET )
request.method = URLRequestMethod.GET;
// creating actual loader
var loader : URLLoader = new URLLoader ();
loader.addEventListener( Event.COMPLETE, handleLoaderComplete )
loader.load ( request );
这篇关于AS3 URL 字符串 ->网址请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!