all groups > flash actionscript > april 2006 >
You're in the

flash actionscript

group:

Clearing an array without deleting it



Clearing an array without deleting it DuhChamp
4/29/2006 6:06:10 PM
flash actionscript: What would be the fastest way of clearing an array without deleting it? Could
you set all values to null or undefined and it would work? For example, say I
have an array of 4 numbers: 3, 4, 5, 6. Now, for some reason I want to clear
all the values and set only one value, so now I have an array of 1 number with
a length of only 1: 7. How can I do this without deleting the array? Remeber,
I only want this array to have a length of one, not 4.
Re: Clearing an array without deleting it Marghoob Sulemaan
4/29/2006 6:31:53 PM
u could try this one may be it should work for ur requirements.

var myArray:Array = new Array(1, 3, 4, 5)
myArray.length = 1;
trace(myArray)

AddThis Social Bookmark Button