0

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

zak kus
  • 41
  • 1
  • 5

1 Answers1

2

what's wrong with a Vector ?

var barArr:Vector.<BarClass> = new Vector.<BarClass>();
George Profenza
  • 50,687
  • 19
  • 144
  • 218
  • 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 Jan 16 '10 at 01:50
  • 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 Jan 16 '10 at 04:15
  • 2
    @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 Jan 18 '10 at 15:07
  • @invertedSpear thats not a bad idea! Cheers – zak kus Jan 18 '10 at 18:36