2016-10-13 00:16:48 点击量:7 标签: 收藏本文
用as3实现了数组元素的分页:
代码如下:
Page 类
- package pages
- {
- public class Page
- {
- private var array:Array;
- private var _index:int;
- private var _capacity:int = 0;
- public function Page()
- {
- array=new Array();
- }
- /**
- *添加
- * @param item
- *
- */
- public function add(item:Object):void
- {
- if (array.length < _capacity)
- {
- array.push(item);
- }
- }
- public function get capacity():int
- {
- return _capacity;
- }
- /**
- *删除
- * @param index
- * @return
- *
- */
- public function remove(index:int):Object
- {
- var obj:Object = null;
- if (index in array)
- {
- obj = array.splice(index,1);
- }
- return obj;
- }
- /**
- *项目索引
- * @param item
- * @return
- */
- public function indexOf(item:Object):int
- {
- var index:int = -1;
- for (var i:int=0; i < array.length; i++)
- {
- if (item === array[i])
- {
- iindex = i;
- break;
- }
- }
- return index;
- }
- /**
- *页序号
- * @return
- *
- */
- public function get index():int
- {
- return _index;
- }
- public function set capacity(capacity:int):void
- {
- if (capacity >= 0)
- {
- _capacity = capacity;
- }
- }
- /**
- *数量
- * @return
- *
- */
- public function get count():int
- {
- return array.length;
- }
- /**
- *是否为空
- * @return
- */
- public function empty():Boolean
- {
- return array.length == 0;
- }
- public function set index(value:int):void
- {
- if (value >= 0)
- {
- _index = value;
- }
- }
- /**
- *项目集合
- * @return
- */
- public function get items():Array
- {
- return array;
- }
- /**
- *页的描述
- * @return
- */
- public function toString()
- {
- return array.toString();
- }
- }
- }
我们是一家提供综合软件外包与弱电工程服务的技术公司。
业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。
公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室