首页 > 其他 > 详细

[ActionScript3.0] 为内建类添加方法

时间:2015-02-14 17:23:43      阅读:274      评论:0      收藏: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

[ActionScript3.0] 为内建类添加方法

原文:http://www.cnblogs.com/frost-yen/p/4291985.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!