  | |  | Re: Find stuff in Flash array? | Re: Find stuff in Flash array? 2003-12-03 - By Daniel Isenhower
Back > Does anyone here have knowlege of Flash arrays? > Say I've got an Array(1,3,5,7,11). How can I find out if 3 is in the array?
...and just to clarify what I've already been through:
I obviously can't access it like this:
var someNumbers = Array(1,3,5,7,11); var lookingFor = 3; trace(someNumbers[lookingFor]);
...becuase that would return 7. I've also tried it like this:
var someNumbers = Array(1,3,5,7,11); var lookingFor = 3; trace(someNumbers[String(lookingFor)]);
...and it returns "undefined". Not that I was expecting that to work anyway, but I'm getting desparate. Is there no other way other than looping through the entire array?
var someNumbers = Array(1,3,5,7,11); var lookingFor = 3; for (var i in someNumbers) { if (someNumbers[i] == lookingFor) { trace("i've found it the inefficient way :-/"); } }
...the array could potentially be very big. I would think that would slow down my project quite a bit eventually.
Surely there's another way? I've looked through the AS help and on macromedia.com, but to no avail :(
-Daniel www.triinfinite.net www.freewebhome.com www.fervorstudios.com
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ dirGames-L mailing list - dirGames-L@(protected) http://nuttybar.drama.uga.edu/mailman/listinfo/dirgames-l
Earn $52 per hosting referral at Lunarpages.
|
|
 |