Reputation: 14085
How can I have a string list in ActionScript-3 ? I don't want to just use an array and always check for type or be type vulnerable. If I could make arrays type specific that would help me. In C# I can do:
List<string> list = new List<string>();
list.Add("hello world");
string str = list[0];
I wished I could do more or less the same in AS-3.
Upvotes: 1
Views: 700
Reputation: 39466
You can use the Vector
type, like this:
var list:Vector.<String> = new <String>[];
// or new Vector.<String>();
list.push("hello world");
var str:String = list[0];
Note that AS3's Vector
class lacks some functionality found in C#'s List<T>
like Remove()
, and includes some functionality you would find in other classes of C# such as pop()
, typically found in Stack<T>
.
Upvotes: 3
Reputation: 1193
In AS3 you can use Vector
datatype.
See More info on Vector data type
Upvotes: 1
Reputation: 1153
Vector
class works the same way as you need.
See http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Vector.html.
Upvotes: 0