Why not throw another option in the mix :)
I think this one is more efficient because it only loops through the
number array once at the beginning... but I'm not an optimization
expert.
// define your array of "bad" numbers
var nList_array:Array = new Array(12, 34, 21, 46, 52)
// create an object with a boolean value for each "bad" number
var nList_object:Object = new Object();
for (var i:Number = 0; i<nList_array.length; i++){
var num:Number = nList_array[i];
nList_object["bad"+num] = false;
}
// create a function to "test" a number;
function testNumber(num:Number):Boolean
{
if (nList_object["bad"+num] === false){
return false;
} else {
return true;
}
}
// Now test it
for (var i:Number = 0; i<100; i++){
if (testNumber(i)){
trace("doing something with "+i);
} else {
trace("BAD NUMBER: "+i);
}
}
On Dec 20, 2006, at 4:42 PM, Eduardo Barbosa wrote:
Hi all,
given a list of numbers such as: (12, 34, 21, 46, 52 ... )
what would be the best way to achieve this:
a++;
if ( a != 12 && a != 34 && a != 21 && a != 46 && a != 52 ... ) {
// do something
}
Am doing my research and trying out some solutions but i thought
that in the
meantime someone may have a quick ready answer for this or some
good hints.
thanks a lot!
Eduardo
_______________________________________________
[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
This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed. If
you are not the named addressee you should not disseminate, distribute or copy
this e-mail Please notify the sender immediately by e-mail if you have
received this e-mail by mistake and delete this e-mail from your system. Any
other use, retention, dissemination, forwarding, printing or copying of this
e-mail is strictly prohibited. Finally, the recipient should check this e-mail
and any attachments for the presence of viruses. Lambesis accepts no liability
for any damage caused by any virus transmitted by this email.
_______________________________________________
[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