1

I have a URLVariables object (variables) that I'm setting its properties this way.

variables.fname = "fname";
variables.lname = "lname";
variables.address = "address"; 

But the properties differ so I want to just pass an object in the following format and have it set the property names and values correctly.

{fname: "fname", lname: "lname", address: "address"}

I tried a forloop like this, but it's not working. Not sure exactly how I achieve the same thing as setting the properties manually.

var variables:URLVariables = new URLVariables ();
for(var key:String in params){
   variables.key = String(params[key]);
}

1 Answer 1

6

You could simply do like this:

var variables:URLVariables = new URLVariables();
for(var key:String in params){
   variables[key] = String(params[key]);
}
Sign up to request clarification or add additional context in comments.

1 Comment

I have to wait 3 more minutes. There's some kind of a limit set here, but I upvoted already, thanks :)

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.