Help with basic loops (im being a muppet)

Hi there- I having some problems with a really simple loop that i cant quite figure out whats wrong. I want to scroll through an array of elements (strings such as as, al, sa, etc), and remove a certain element from the array when it gets to it. here i have used “sa”… below is my code

//loads shared object

this.mySO = SharedObject.getLocal(“test”, “/”);

mySO.data.theArray2 = new Array();
alength = mySO.data.theArray.length;

for (i = 0; i < alength; i ++ )
{
if (mySO.data.theArray* = “sa”)
{
mySO.data.theArray2 = mySO.data.theArray.slice(i);
}

}

trace (mySO.data.theArray);
trace (mySO.data.theArray2);

here i have tried to create a new array by slicing off the part that i dont want. i think this method wiull shuffle all the other elements down to create a new array 1 space shorter and with no null elements.

at the moment it seems to be changing ALL elements to sa. Im scratching my head but nothing

any help would be greatly appreciated!!

chimpo

First off all, you made a syntax error:

[AS]if (mySO.data.theArray* == “sa”){
mySO.data.theArray2 = mySO.data.theArray.slice(i);
}[/AS]

= should’ve been ==. I didn’t look it all through, so if it still doesn’t work let us know.

hi- thanks for your reply. i realised that as soon as i posted it.

now though- instead of slicing off “sa” and making array2 one shorter, it is in fact making array2 only consist of sa- ie 1 element long!

any further help?

This should help you out: http://www.kirupa.com/developer/actionscript/array.htm