I have an array Items which has 10 elements. I need to remove the 5th element (index=4) the new array should ha开发者_运维知识库ve 9 elements and all elements after the 5th element will be shifted forward
what command(s) should i use?
Splice
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Array.html#splice%28%29
var vegetables:Array = new Array("spinach",
"green pepper",
"cilantro",
"onion",
"avocado");
var spliced:Array = vegetables.splice(2, 2);
trace(vegetables); // spinach,green pepper,avocado
trace(spliced); // cilantro,onion
vegetables.splice(1, 0, spliced);
trace(vegetables); // spinach,cilantro,onion,green pepper,avocado
精彩评论