Container


继承 Container View 模块 hilo/view/Container 依赖 hilo/core/Hilo, hilo/core/Class, hilo/view/View 源码 Container.js
Container是所有容器类的基类。每个Container都可以添加其他可视对象为子级。

属性概览

显示继承属性
属性 定义于
children:Array
容器的子元素列表。只读。
Container
clipChildren:Boolean
指示是否裁剪超出容器范围的子元素。默认为false。
Container
pointerChildren:Boolean
指示容器的子元素是否能响应用户交互事件。默认为true。
Container

方法概览

显示继承方法
方法 定义于
Container(properties:Object)
构造函数
Container
addChild(child:View)
在最上面添加子元素。
Container
addChildAt(child:View, index:Number)
在指定索引位置添加子元素。
Container
contains(child:View)
返回是否包含参数指定的子元素。
Container
getChildAt(index:Number)
返回指定索引位置的子元素。
Container
getChildById(id:String)
返回指定id的子元素。
Container
返回指定子元素的索引值。
Container
返回容器的子元素的数量。
Container
getViewAtPoint(x:Number, y:Number, usePolyCollision:Boolean, global:Boolean, eventMode:Boolean)
返回由x和y指定的点下的对象。
Container
removeAllChildren():Container
删除所有的子元素。
Container
removeChild(child:View):View
删除指定的子元素。
Container
removeChildAt(index:Int):View
在指定索引位置删除子元素。
Container
removeChildById(id:String):View
删除指定id的子元素。
Container
setChildIndex(child:View, index:Number)
设置子元素的索引位置。
Container
sortChildren(keyOrFunction:Object)
根据指定键值或函数对子元素进行排序。
Container
swapChildren(child1:View, child2:View)
交换两个子元素的索引位置。
Container
swapChildrenAt(index1:Number, index2:Number)
交换两个指定索引位置的子元素。
Container

属性详情

children:Array
容器的子元素列表。只读。
clipChildren:Boolean
指示是否裁剪超出容器范围的子元素。默认为false。
pointerChildren:Boolean
指示容器的子元素是否能响应用户交互事件。默认为true。

构造函数

Container(properties:Object)
parameters
properties:Object — 创建对象的属性参数。可包含此类所有可写属性。

方法详情

addChild(child:View)
在最上面添加子元素。
parameters
child:View — 要添加的子元素。
addChildAt(child:View, index:Number)
在指定索引位置添加子元素。
parameters
child:View — 要添加的子元素。
index:Number — 指定的索引位置,从0开始。
contains(child:View)
返回是否包含参数指定的子元素。
parameters
child:View — 指定要测试的子元素。
getChildAt(index:Number)
返回指定索引位置的子元素。
parameters
index:Number — 指定要返回的子元素的索引值,从0开始。
getChildById(id:String)
返回指定id的子元素。
parameters
id:String — 指定要返回的子元素的id。
getChildIndex(child:View)
返回指定子元素的索引值。
parameters
child:View — 指定要返回索引值的子元素。
getNumChildren():Uint
返回容器的子元素的数量。
return
Uint — 容器的子元素的数量。
getViewAtPoint(x:Number, y:Number, usePolyCollision:Boolean, global:Boolean, eventMode:Boolean)
返回由x和y指定的点下的对象。
parameters
x:Number — 指定点的x轴坐标。
y:Number — 指定点的y轴坐标。
usePolyCollision:Boolean — 指定是否使用多边形碰撞检测。默认为false。
global:Boolean — 使用此标志表明将查找所有符合的对象,而不仅仅是第一个,即全局匹配。默认为false。
eventMode:Boolean — 使用此标志表明将在事件模式下查找对象。默认为false。
removeAllChildren():Container
删除所有的子元素。
return
Container — 容器本身。
removeChild(child:View):View
删除指定的子元素。
parameters
child:View — 指定要删除的子元素。
return
View — 被删除的对象。
removeChildAt(index:Int):View
在指定索引位置删除子元素。
parameters
index:Int — 指定删除元素的索引位置,从0开始。
return
View — 被删除的对象。
removeChildById(id:String):View
删除指定id的子元素。
parameters
id:String — 指定要删除的子元素的id。
return
View — 被删除的对象。
setChildIndex(child:View, index:Number)
设置子元素的索引位置。
parameters
child:View — 指定要设置的子元素。
index:Number — 指定要设置的索引值。
sortChildren(keyOrFunction:Object)
根据指定键值或函数对子元素进行排序。
parameters
keyOrFunction:Object — 如果此参数为String时,则根据子元素的某个属性值进行排序;如果此参数为Function时,则根据此函数进行排序。
swapChildren(child1:View, child2:View)
交换两个子元素的索引位置。
parameters
child1:View — 指定要交换的子元素A。
child2:View — 指定要交换的子元素B。
swapChildrenAt(index1:Number, index2:Number)
交换两个指定索引位置的子元素。
parameters
index1:Number — 指定要交换的索引位置A。
index2:Number — 指定要交换的索引位置B。