如果您有一个包含六个数字的数组,请说:
public var check:Array = new Array[10,12,5,11,9,4];
或者
public var check:Array = new Array[10,10,5,11,9,4];
你如何检查匹配(一对?)
最佳答案
Array
类(class)有一个 indexOf
method :
function indexOf(searchElement:*, fromIndex:int = 0):int
Searches for an item in an array by using strict equality (===) and returns the index position of the item.
Parameters
searchElement:*
— The item to find in the array.fromIndex:int
(default = 0) — The location in the array from which to start searching for the item.Returns
- int — A zero-based index position of the item in the array. If the
searchElement
argument is not found, the return value is -1.
关于actionscript-3 - ActionScript 3 : Check an array for a match,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2046364/