AS3 URL字符串 - >的URLRequest [英] AS3 URL string -> URLRequest

查看:112
本文介绍了AS3 URL字符串 - >的URLRequest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用一些加载器不接受 products.php?猫= 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字符串 - >的URLRequest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆