Mailing List
Home
Forum Home
MUD Dev - Discussion of MUD system design, development, and implementation
Mac Game - Mac game development
Rivers of MUD - a Diku and Merc based multiuser dungeon
SMAUG
Subjects
Getting UDP through NAT/firewalls/whatever for a game
Getting UDP through NAT/firewalls/whatever for a game
QuickTime errors
Python script as stand alone MUD server
Various sound problems
Fragment Shaders & GL TEXTURE RECTANGLE EXT
Timers and global variables
Re: Language and platform for Text MUD server
Apparent acquisition of Yantis (mysupersales) by IDE
HID keyboard
Getting UDP through NAT/firewalls/whatever for a game
Microsoft Sparkle
Director MX
Congratulations Horizons
Yet more problems fullscreen mode
Apple Dev Kitchen Them 's tasty vittles, Maw!
NSOpenGLContext, Pbuffers, and drawables
More DCR "theft " naughtiness
dynamic sprite creation and imaging lingo
Re: Find stuff in Flash array?
Effects of skill imbalances?
QuickTime errors
Rom 2 4/Quickmud Enhancement/Bug fix
Working with XML files/CFURL
smooth scrolling/subpixel tweening
RE: (Ron help me?) Flash text
Flash Racing
MudDev FAQ 2
Browser based games
Installing GLUT
Special character in Flash XML
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
Re: Find stuff in Flash array?

Re: Find stuff in Flash array?

2003-12-03       - By Hubert Spall

 Back
Reply:     1     2     3  

Looping throught the array is the only way to do it. This is the case in any
language, though some (e.g. lingo) include wrapper functions which hide the
fact that this is what is happening. However, you will find lingo functions
such as List.getOne() to be slow too when dealing with a large list, they
aren't very much more efficent than looping (though there will be some
optimisations made by writing the wrapper in a low level language rather than
e.g. actionscript). Flash will be slower still, but only because it generally
is, not because it has to loop.

If your data set is sorted this will help narrow the search - look into
Array.sort() and Array.sortOn() - you could add custom array methods to search
only particular parts of a sorted list. Or you could break your data into
categories, and only search the relevent categories, not the whole list.

But if your array is simply a flat list, there is no logical way to retrieve
specific items other than checking one by one for a match.

Hubert


Quoting Daniel Isenhower <jml@(protected)>:

> > 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
>
>
__ ____ ____ ____ ____ ____ ____ ____ ____ ____
dirGames-L mailing list  -  dirGames-L@(protected)
http://nuttybar.drama.uga.edu/mailman/listinfo/dirgames-l

Earn $52 per hosting referral at Lunarpages.