Flasher Archive

[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]

Subject: Re: [flasher] RE: array.indexOf
From: Scott Rouse
Date: Mon, 29 Jan 2001 17:15:22 -0000

That is what I ended up doing...created a general function to find it and
stored the value in "arrayIndex" and made sure to jump out of the loop after
I found a match. I was told by my programmer friend that I was spoiled by
Director and that most most of the Array functions that I am used to has to
be coded like such in most other languages...oh well, got it and it works
quickly and gets me what I need. Thanks for all of your help!

function arrayIndexFinder (a, b) {
//a is the name of the Array and b is the string to find in the Array
arrayCount = 0;
while (arrayCount<=a.length) {
if (a[arrayCount] == b) {
arrayIndex = arrayCount;
arrayCount = a.length+1;
arrayCount += 1;
----- Original Message -----
From: "Phillip Kerman" <flash5atteleport [dot] com>
To: "flasher from chinwag" <flasheratlists [dot] chinwag [dot] com>
Sent: Monday, January 29, 2001 10:25 AM
Subject: [flasher] RE: array.indexOf

> You could also just write a loop that goes through each item in the array
> until it finds what you're looking for... then note what index it was
> in.
> It may seem like a slow proposition (stepping through as many as all the
> items) but arrays are generally very fast to search through.
> Here's the pseudo-code:
> searchFor="thing I'm looking for";
> for (i in myarray){
> if (i==searchFor){
> break;
> }
> }
> trace("it was found in spot "+ i);

[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]