Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
Posts: 297
Registered: ‎10-30-2010
My Device: PlayBook
My Carrier: other

Array insertAtIndex removeObjectAtIndex objectAtIndex ??

What kind of language is this.. don't like it so far..

 

I looked in the documentation of Array class.. it has no methods to insert or remove objects at index. How to access object at index?

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Array insertAtIndex removeObjectAtIndex objectAtIndex ??

hey,

 

no need to worry, these functions are available just not as obvious as they should be.

 

to access a specific object at an index simply do this:

 

 

var myArray:Array = new Array();

myArray.push("Something cool.");
myArray.push("Something else.");

(...)

trace("Item in the second position: " + myArray[1]);

 

 

and to delete an object at a specific position use the splice method:

 

 

var myArray:Array = new Array();

myArray.push("Something cool.");
myArray.push("Something else.");

(...)

myArray.splice(1,1);

 

This will delete the item at the second position (index = 1).

 

 

Here are more details about the splice method:

 

http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/Array.html#splice()

 

hope that clears things up. good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman