Actionscript Question
- Started
- Last post
- 9 Responses
- nosaj
Is ther an easy way to write a comparision that checks to see if a variable is equal to any of the values of an array?
ie:
myArray = [1,4,10]
if mcCheck = (any of the values of my Array) {do something}
- tomkat0
for[i=0; i smaller arraylength, i++]
if[myArray[i] == myVal] doSomething
- UndoUndo0
for(i=0; i < array.length, i++){
if(myArray[i] == myVal){doSomething
}
};as tomakt said
- unfittoprint0
myArray = [1,4,10]
for (i=0; i < myArray.length; i++){
if (myCheck == myArray[i]){
trace( "myCheck equals myArray["+i+"]");
}
}
- E__________0
I've got the shortest!!!
var i;
while(myArray[i] != myVar)
i++;
trace(i)
- E__________0
sorry wrong there:
var i;
while(myArray[i] != myVar && myArray[i] != undefined)
{ i++; }
trace(i);
- UndoUndo0
haha E_____ who told you small was better?
:P
- nosaj0
Awesome - thanks all... and mines the biggest:
for (i=0; i
- nosaj0
for (i=0; i
- E__________0
ah just some wishful thinking my man.