views:

38

answers:

2

Like java, I want to create a method that accepts an array list of particular object type.

In java:

public void addStudents(List<Student> students) {
...
}

In actionscript

public function addStudents(students:ArrayCollection):void {
.....
}

Here I want to have public function addStudents(students:ArrayCollection).

Thanks

+1  A: 

As far as i know, AS has no template-like generics. But you can extend ArrayCollection into something like StudentArrayCollection with more rigid type check inside.

DoubleThink
thanks for your input.
priyank
+3  A: 

If you have a Student object and publish for FP10 you can use the Vector object.

public function addStudents(students:Vector.<Student>):void {}

For further information: http://help.adobe.com/en_US/AS3LCR/Flash_10.0/Vector.html

Tobias Kun