Class > Query Vars to Flash - ASP Style

I recently had a flash project that required me to get query string variables and found it cumbersome, however i found a query string class here on the forums originally created by MichaelxxOA over at…31&postcount=2

I reqrote it and structured it to act like Request.QueryString() familiar to those that have worked with asp and aspx.

I also added some functionality to datatype the variables as well. For example, and numeric variable value will become a number once it is pulled in and a true or false will be converted to Boolean.

Anyway, I figured I would share…

//External Interface Class
import flash.external.ExternalInterface;

class Request

    //Switch to Load Vars if they haven't already been loaded
    private static var hasLoaded:Boolean = false;
    //Define Javascript Function
    private static var getURLFunction:String = "function get_url(){return window.location.toString();}";
    //Array to store values once they have been loaded.
    private static var values:Array = new Array();

    public function Request(){}
    //--Query String
    public static function QueryString(varName:String)
        //Pull Valuse From Query String if you havent already.
            hasLoaded = true;
        return values[varName];
    //--Get Values From Query String
    private static function getValueArray():Void
        trace("]> Loading Variables from Query String.");
        var o:Array = new Array();
        //Call Javascript Function
        o ="?")[1].split("&");
        for(var i:Number = 0; i < o.length; i ++)
            var tempName:String = o*.split("=")[0];
            var tempValue:String = o*.split("=")[1];
            trace("  - " + tempName + " = " + tempValue);
                //Datatype value as a Number
                values[tempName] = Number(tempValue);
            }else if(tempValue.toLowerCase() == "true" || tempValue.toLowerCase() == "false"){
                //DataType value as a Boolean
                values[tempName] = Boolean(tempValue);
                values[tempName] = tempValue;

This is how you would use it
[FONT=Courier New]

var qsVar = Request.QueryString("varName");