Search code examples
apache-flexactionscript-3actionscriptairblackberry-playbook

Collection of typed Objects


How do you create a collection of objects, where we declare the object typed used in the collection?

For example in Java you can do:

List<Person> where Person is the object type.

In AS3/Flex

ArrayCollection which takes any object type.

Is there any way to create a list/collection of declared objects in AS3/Flex (or is it impossible due to weakly typed language)?

Thanks Phil


Solution

  • You can create a Vectorobject which is an array whose elements are all the same type:

    var stringVector:Vector.<String> = new Vector.<String>();