Question : How to search for an multiple elements in an array in actionscript 3.0

Let me start off by saying that I am completely new to Actionscript 3.0....
I was wondering if and how you can search for multiple elements in an array in actionscript 3.0.  For example:

my array has the elements (1,3,5,7,6,8)

I want to search my array for (3,6,8).  do I have to do array1.indexOf(3), array1.indexOf(8), & array1.indexOf(8), or is there a way I can just do array1.indexOf(3,6,8).  I don't need to know their location within the array, i just need to know if they are in the array or not.  Thanks.

Answer : How to search for an multiple elements in an array in actionscript 3.0

You can't do it as simply as you stated, but you could do something like this:

var arr:Array = new Array(1,3,5,7,6,8);
var testarray:Array = new Array(3,6,8);

var found:Boolean = true;

var j:String;
for(j in testarray){
      (checkIt(testarray[j]));
}


function checkIt(obj:Object):void{
      if(arr.indexOf(obj) < 0){
            found = false;            
      }
}

trace("found all elements = "+found);

Random Solutions  
 
programming4us programming4us