[ActionScript3.0] 为内建类添加方法
通过使用prototype在继承内建类特性的同时加入新方法
Array.prototype.removeElement = function (item:*):void {
var index:int = this.indexOf(item);
if(index>-1){
this.splice(index,1);
}
}
var arr:Array = [1,2,3];
arr.removeElement(1);
trace(arr);//2,3
------------------------------------------------------------------
Always put yourself in the other's shoes.If you feel that it hurts you,it probably hurts others,too.------------------------------------------------------------------