2

I have an array Items which has 10 elements. I need to remove the 5th element (index=4) the new array should have 9 elements and all elements after the 5th element will be shifted forward

what command(s) should i use?

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.