3

If I want to send an object to a function with one child called foo equals "bar", i need to do the following:

var obj:Object = new Object();
obj.foo="bar";
myfunction(obj);

is there a way to declare the object in the function itself ? something like that:

myfunction(new Object{foo:"bar"}); 

thank you!

using flash-as3.

1 Answer 1

18

You almost had it in your example!

To create an object inline you use curly braces:

myfunction({foo:"bar"});

You can also do inline arrays with brackets:

myfunction(["bar", "baz"]);
Sign up to request clarification or add additional context in comments.

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.