var testVal:String = "something"; array.filter(someCallbackFunction, testVal); [...] public function someCallbackFunction(element:*, index:int, arr:Array):Boolean { element.isActive = this; }
public function testArray() { var arr:Array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; var filterValArr:Array = [4, 8]; var filtARr:Array; var val:int = filterValArr.length; for (var i:int = 0; i < val; i++) { filtARr = arr.filter( function(item:*, index:int, array:Array):Boolean { return item > this; }, filterValArr[i] ); trace("filtARr test " + i + " = " + filtARr); } }
沒有留言:
張貼留言