Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AS3 URL string -> 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?

like image 973
A-OK Avatar asked Dec 13 '22 12:12

A-OK


1 Answers

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 );
like image 57
Jevgenij Dmitrijev Avatar answered Jan 13 '23 16:01

Jevgenij Dmitrijev