新添加两个属性,省去一点麻烦,使用时把下列代码拷贝到主场景第一帧上即可:
Array.prototype.del = function(pos) {
this.splice(pos, 1);
return this;
};
Array.prototype.find = function(str) {
var arr:Array = this;
var outPos:Number = -1;
for (var i = 0; i<arr.length; i++) {
if (arr[i] == str) {
outPos = i;
break;
}
}
return outPos;
};
/*调用例子:
var arr:Array = new Array("123", "321", "222");
trace(arr.find("123")); 结果显示 0
*/