A layer-based container for Objects.
Hierarchically organizes objects based on their layer.
Supports per-layer Y-sorting through Layers.ysort
.
Constructor
new(?parent:Object)
Create a new Layers instance.
Parameters:
parent | An optional parent |
---|
Methods
add(s:Object, layer:Int = -1, index:Int = -1):Void
Adds a child object s
at the end of the given layer
.
Parameters:
s | An object to be added. |
---|---|
layer | An index of the layer the object should be added at with 0 being the bottom-most layer. Pass -1 to use topmost layer. |
index | An optional index at which the object should be inserted inside the layer. Pass -1 to append to the end. |
addChild(s:Object):Void
Adds a child object s
at the end of the topmost layer.
Parameters:
s | An object to be added. |
---|
addChildAt(s:Object, index:Int):Void
Adds a child object s
at specified index
on the top topmost layer.
Warning: Previous behavior of Layers.addChildAt
is no longer applicable and Layers.add
should be used instead.
Parameters:
s | The object to be added. |
---|---|
index | The position of the object in the layer. |
getChildAtLayer(n:Int, layer:Int):Object
Return the n
th element among the immediate children list on the layer
, or null if there is none.
Parameters:
layer | The layer children of which are used. Pass -1 to use the topmost layer. |
---|
getChildIndexInLayer(o:Object):Int
Return the index of the child within its respective layer.
Parameters:
o | The child to look up index of. |
---|
Returns:
-1
if object is not a child of Layers, index of the child within its current layer otherwise.
getChildLayer(s:Object):Int
Returns the layer on which the child s
resides on.
Parameters:
s | An object to look up to. |
---|
Returns:
An index of the layer where the object resides on or -1
if s
is not a child of the Layers.
getLayer(layer:Int):Iterator<Object>
Returns an Iterator with objects in a specified layer
.
Returns an empty iterator if no objects are present in the layer.
Objects added or removed from Layers during iteration do not affect the output of the Iterator.
Parameters:
layer | A layer index to iterate over. |
---|
over(s:Object):Void
Moves an object s
to the top of its layer (rendered last, in front of other Objects in layer).
Causes Object.onHierarchyMoved
on the Object.
Parameters:
s | An object to be moved. |
---|
under(s:Object):Void
Moves an object s
to the bottom of its layer (rendered first, behind the other Objects in the layer).
Causes Object.onHierarchyMoved
on the Object.
Parameters:
s | An object to be moved. |
---|
ysort(layer:Int):Void
Sorts specified layer based on Object.y
value of it's children.
Causes Object.onHierarchyChanged
on moved children.
Parameters:
layer | An index of the layer to sort. |
---|