A generalized array-searching function : Search : Array Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Array » Search »

 

A generalized array-searching function


 


package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){


        var soundtracks:Array = ["e""h","p""a""c"];
        
        trace(searchArray(soundtracks,"h"));
        
            }
        function searchArray (theArray:Array, searchElement:Object):int {
          for (var i:int 0; i < theArray.length; i++) {
            if (theArray[i== searchElement) {
              return i;
            }
          }
          return -1;
        }

  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Array
» Search