views:

163

answers:

1

Hi.

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.

+6  A: 

You almost had it in your example!

To create an object inline you use curlybraces:

myfunction({foo:"bar"});

You can also do inline arrays with brackets:

myfunction(["bar", "baz"]);
grapefrukt
thanks a lot! :)
ufk