public function removeItemAt(index:int):Object { if (index < 0 || index >= length) { var message:String = resourceManager.getString( "collections", "outOfBounds", [ index ]); throw new RangeError(message); }
var listIndex:int = index; if (localIndex) { var oldItem:Object = localIndex[index]; listIndex = list.getItemIndex(oldItem); } return list.removeItemAt(listIndex); }
public function findEmployeeInSource(id:int):OrgEmployee { var obj:OrgEmployee = null; var list:IList = employees.list; var len:int = list.length; for (var index:int = 0; index < len; index++) { obj = list.getItemAt(index) as OrgEmployee; if (obj.id == id) { return obj; } } return null; }
public function deleteEmployee(id:int):void { var obj:OrgEmployee = findEmployeeInSource(id); if (obj != null) { var index:int = employees.list.getItemIndex(obj); employees.list.removeItemAt(index); } }
或者一个函数:
复制代码 代码如下:
public function deleteEmployee(id:int):void { var obj:OrgEmployee = null; var list:IList = employees.list; var len:int = list.length; for (var index:int = 0; index < len; index++) { obj = list.getItemAt(index) as OrgEmployee; if (obj.id == id) { list.removeItemAt(index); return; } } }