How to declare a filled vector?

I use Vectors in Flash 10 for the first time, and I want to create it the same way I did with arrays, for example:

var urlList : Array = [url1, url2, url3]; 

I tried different methods, but none of them work, and I decided to solve the following:

 var urlList : Vector.<String> = new Vector.<String>(); urlList.push(url1, url2, url3); 

Is it possible?

+4
source share
2 answers

If in doubt, check out the AS3 docs. :)

 var urlList : Vector.<String> = new <String>["str1", "str2", "str3"]; trace(urlList); 

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Vector.html#Vector ()

A direct quote from a line that I adapted in the documentation:

To create a pre-populated Vector instance, use the following syntax instead of using the options listed below:

  // var v:Vector.<T> = new <T>[E0, ..., En-1 ,]; // For example: var v:Vector.<int> = new <int>[0,1,2,]; 
+20
source

You force the array to a vector:

 var urlList:Vector.<String> = Vector.<String>([url1, url2, url3]); 
+6
source

All Articles