2

I want to fetch some parameters from a url on to my flex web application. How can I do that?

For example I want to fetch the parameters name and age from the url http://www.abc.com?name=vkwave&age=25 on to my flex application

Your help would be appreciated

2 Answers 2

6
var pageURL : String = ExternalInterface.call("window.location.href.toString");
var paramPairs : Array = pageURL.split("?")[1].split("&");
for each (var pair : String in paramPairs)
{
    var param : Array = pair.split("=");
    trace("key: " + param[0] + ", value: " + param[1]);
}
Sign up to request clarification or add additional context in comments.

Comments

0

In index.template.html add an if statement betweeen var flashvars and var params:

var flashvars = {};
if (swfobject.getQueryParamValue("name") && swfobject.getQueryParamValue("age"))
{   
    flashvars.name = swfobject.getQueryParamValue("name");
    flashvars.age= swfobject.getQueryParamValue("age");
}
var params = {};

In Main.mxml

<s:Application ...  creationComplete="init()">

import mx.controls.Alert;
import mx.core.FlexGlobals;

private function init():void {

for (var i:String in FlexGlobals.topLevelApplication.parameters) {
    Alert.show( i + ":" + FlexGlobals.topLevelApplication.parameters[i] + "\n");
}

Will output name:vkwave

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.