//Create array with 5 elements
var myArray1:Array = new Array();
myArray1.push( new Array("A:", -1) );
myArray1.push( new Array("B:", -1) );
myArray1.push( new Array("C:",  0) );
myArray1.push( new Array("D:",  0) );
myArray1.push( new Array("E:", -1) );
myArray1.push( new Array("F:",  1) );
myArray1.push( new Array("G:",  0) );
myArray1.push( new Array("H:", -1) );

var i:Number = 0;
while(myArray1[i]){
        if(myArray1[i][1] < 0){
                myArray1.splice(i, 1);
        }else{
                i++;
        };
};
delete i; // ^_^



- - - - - - - - -
-[andrew murphy]-
flash developer
[EMAIL PROTECTED]

delvinia interactive inc.
214 king street west, suite 214
toronto canada M5H 3S6
voice 416.364.1455 ext. 232
cell 416.820.8723
fax 416.364.9830
www.delvinia.com

CONFIDENTIALITY NOTICE
This email message may contain privileged or confidential information. If
you are not the intended recipient or received this communication by error,
please notify the sender and delete the message without copying or
disclosing it.

AVIS DE CONFIDENTIALITÉ
Ce message peut contenir de l'information légalement privilégiée ou
confidentielle. Si vous n'êtes pas le destinataire ou croyez avoir reçu par
erreur ce message, nous vous saurions gré d'en aviser l'émetteur et d'en
détruire le contenu sans le communiquer a d'autres ou le reproduire.


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mike Cobb
Sent: December 21, 2006 11:58 AM
To: Flashcoders mailing list
Subject: [Flashcoders] Remove elements from Array

-

Hi everyone,

I'm having a braindead moment today, which I was hoping someone could help
me with.

I have the following array...

//Create array with 5 elements
var myArray1:Array = new Array();
myArray1.push( new Array("A:", -1) );
myArray1.push( new Array("B:", -1) );
myArray1.push( new Array("C:",  0) );
myArray1.push( new Array("D:",  0) );
myArray1.push( new Array("E:", -1) );
myArray1.push( new Array("F:",  1) );
myArray1.push( new Array("G:",  0) );
myArray1.push( new Array("H:", -1) );
                        //name, score

...and I'm trying to remove all the elements in myArray1 with a score of
less than 0 without sorting/reordering the array at all.

I was trying to use a 'for loop', but obviously as the elements are removed,
the length of the array changes & causes the wrong elements to be deleted.

Can anyone help?

Thanks,
<Mike>

--
-------------------------------------
Mike Cobb
Creative Director
HMC Interactive
-------------------------------------
Tel: + 44 (0)845 20 11 462
Mob: + 44 (0)785 52 54 743
Web: http://www.hmcinteractive.co.uk
-------------------------------------
Grosvenor House, Belgrave Lane,
Plymouth, PL4 7DA, UK.
-------------------------------------

I've got a new e-mail address: [EMAIL PROTECTED] Please update your
address book. Thanks.

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training http://www.figleaf.com
http://training.figleaf.com

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.15.26/594 - Release Date: 20/12/2006
3:54 PM
 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.15.26/594 - Release Date: 20/12/2006
3:54 PM
 

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to