views:

40

answers:

1

I'm trying to create a class that contains an array. However i want to require that the items in the array are themselves of a specific class. Im told there is some sort of tag you can add to do this, but for the life of me i cannot find what it is.

What i hope for is something like:

public class myClass{
    public var foo:String;

    [ArrayType(class="BarClass")]
    public var barArr:Array 
}

Cheers

+2  A: 

what's wrong with a Vector ?

var barArr:Vector.<BarClass> = new Vector.<BarClass>();
George Profenza
I did not know about this Class; it looks exciting. However its a actionscript 3.5 and class we are still using AS 3.0 for this project.I found what i was originally looking for: the [ArrayElementType] metatag. However it doesn't do what i was looking for (works only for mxml definitions)
zak kus
There is no such thing as AS 3.5 - Just AS3 that has added APIs since it's initial release in Flash Player 9. I believe that Vector was added in something like 9.0.124.
James Ward
@James I am willing to bet zak is referring to the Flex SDK 3.5 vs 3.0. @zak you can go to the open source page (i forget where it is) and get the class that you are missing and add it as a custom class in your project.
invertedSpear
@invertedSpear thats not a bad idea! Cheers
zak kus