Create and define Vector

Posted by zdmytriv on Stack Overflow See other posts from Stack Overflow or by zdmytriv
Published on 2010-05-11T23:53:28Z Indexed on 2010/05/12 1:24 UTC
Read the original article Hit count: 179

Filed under:
|

I'm looking for method to create Vector and push some values without defining variable Vector. For example:

I have function:

public function bla(data:Vector.<Object>):void { ... }

this function expects Vector as parameter. I can pass parameters this way

var newVector:Vector.<Object> = new Vector.<Object>();
newVector.push("bla1");
newVector.push("bla2");
bla(newVector);

Can I do it in one line in Flex? I'm looking for something like:

bla(new Vector.<Object>().push("bla1").push("bla2"));

I've also tried this:

bla(function():Vector.<Object> { var result:Vector.<Object> = new Vector.<Object>(2, true); result.push("bla1"); result.push("bla2"); return result; });

But it complains:

1067: Implicit coercion of a value of type Function to an unrelated type __AS3__.vec:Vector.<Object>...

Thanks

© Stack Overflow or respective owner

Related posts about flex

Related posts about actionscript-3