1

I am new to ActionScript and Flex.I need to learn the application developed using Flex and ActionScript.I saw an ArrayCollection declaration :

    [Bindable]
    public var someThing:ArrayCollection = new ArrayCollection([[]]);
    
What does that declaration mean.Is it multi dimensional?What is it?

1 Answer 1

2

This would be an ArrayCollection which is a wrapper for an Array basically to give you sort and filter function capabilities (and other methods). The constructor optionally takes an Array as an argument, [] is a new array with no elements. [[]] is an array with one element in it that is an array with no elements in it. So this is saying make a new ArrayCollection with it's source as an array which in turn contains one element that is an empty array. Not sure why they would be doing this, but that's what it does.

To sum up, you can declare and instantiate an array in AS3 like:

var myArray:Array = [];

or

var myArray:Array = new Array();

To add since this is I believe ECMAScript specific as well you can instantiate an object similarly using {}. Such as:

var myObj:Object = {};

or

var myObj:Object = new Object();

Either of these sites is good reference material for AS3:

http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7ee5.html#WS5b3ccc516d4fbf351e63e3d118a9b90204-7ee1

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Array.html

When I first got started with Flex (having a background in HTML/JS, C, C++, and Java) I found these videos to be really useful (if not always 100% correct/up to date, they explain the overarching concepts): http://www.adobe.com/devnet/flex/videotraining.html

Sign up to request clarification or add additional context in comments.

3 Comments

This is not a two dimensional array right...?I guess I am not getting this right.I surfed the net to find any place that uses this syntax.Could you point me to some examples or documentation for this?My application is new to me and I am not getting the whole picture.I saw that they are using that "someThing" as a dataprovider.Since it is bindable ,it has to be populated somewhere right?
Correct this isn't a two dimensional array, rather this is an array with an array as it's first element and nothing else in it. If you're using FlashBuilder or the Eclipse plugin you should be able to highlight the variable someThing then right click on it and select References -> Workspace, it may take a minute but it should show you panel with all assignments or reading from that variable. As you say it must be populated somewhere, also refresh would need to be called or the dataProvider would have to be reassigned for it to reflect updates in UI components.
No problem best of luck, it's a ton of fun and hard to pull yourself away from once you get into it, great pull on the name too.

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.