03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

var myPets_array:Array = new Array("cat", "dog", "bird", "fish");<br />

trace( myPets_array.splice(1) ); // Displays dog,bird,fish.<br />

trace( myPets_array ); // cat<br />

The following example creates an array <strong>and</strong> splices it by using element index 1 for the<br />

startIndex parameter <strong>and</strong> the number 2 for the deleteCount parameter. This removes two<br />

elements from the array, starting with the second element, leaving the first <strong>and</strong> last elements<br />

in the original array:<br />

var myFlowers_array:Array = new Array("roses", "tulips", "lilies",<br />

"orchids");<br />

trace( myFlowers_array.splice(1,2 ) ); // Displays tulips,lilies.<br />

trace( myFlowers_array ); // roses,orchids<br />

The following example creates an array <strong>and</strong> splices it by using element index 1 for the<br />

startIndex parameter, the number 0 for the deleteCount parameter, <strong>and</strong> the string chair<br />

for the value parameter. This does not remove anything from the original array, <strong>and</strong> adds the<br />

string chair at index 1:<br />

var myFurniture_array:Array = new Array("couch", "bed", "desk", "lamp");<br />

trace( myFurniture_array.splice(1,0, "chair" ) ); // Displays empty array.<br />

trace( myFurniture_array ); // displays couch,chair,bed,desk,lamp<br />

toString (Array.toString method)<br />

public toString() : String<br />

Returns a string value representing the elements in the specified Array object. Every element<br />

in the array, starting with index 0 <strong>and</strong> ending with the highest index, is converted to a<br />

concatenated string <strong>and</strong> separated by commas. To specify a custom separator, use the<br />

Array.join() method.<br />

Returns<br />

String - A string.<br />

Example<br />

The following example creates my_array <strong>and</strong> converts it to a string.<br />

var my_array:Array = new Array();<br />

my_array[0] = 1;<br />

my_array[1] = 2;<br />

my_array[2] = 3;<br />

my_array[3] = 4;<br />

my_array[4] = 5;<br />

trace(my_array.toString()); // Displays 1,2,3,4,5.<br />

Array 249

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!