Question

In my Flex application I am able to read the variables using something like /flexapp.html?name=josh with no problems. However, this is because I go into the URL and type in the variables by hand. Is there anyway in the code to dynamically append the variable part "?name=josh" ? For example, like retrieving the url and then adding that and then pointing to it?

Was it helpful?

Solution

Or, if you're using a URLRequest, you can format it this way:

package {
    import flash.display.Sprite;
    import flash.net.navigateToURL;
    import flash.net.URLRequest;
    import flash.net.URLVariables;

    public class URLVariablesExample extends Sprite {

        public function URLVariablesExample() {
            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;
            navigateToURL(request);
        }
    }
}

So long as you're using the get method, which is the default.

OTHER TIPS

var myUrl:String = "/flexapp.html";
var myNameVar:String = "josh";
var myVar:String = "?name=" + myNameVar;
myUrl += myVar;

URLs are just strings, so you can use any string methods with them (regex concatenation, etc)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top