* Remove child at index * 移除指定位置的子对象
(index: number, bDispose: boolean = false)
| 123 | * 移除指定位置的子对象 |
| 124 | */ |
| 125 | public removeChildAt(index: number, bDispose: boolean = false): GObject { |
| 126 | if (index < 0 || index >= this._children.length) { |
| 127 | throw new Error('Invalid child index: ' + index); |
| 128 | } |
| 129 | |
| 130 | const child = this._children[index]; |
| 131 | child._parent = null; |
| 132 | |
| 133 | if (child.sortingOrder !== 0) { |
| 134 | this._sortingChildCount--; |
| 135 | } |
| 136 | |
| 137 | this._children.splice(index, 1); |
| 138 | |
| 139 | if (child.internalVisible) { |
| 140 | const childDisplay = child.displayObject; |
| 141 | if (this._displayObject && childDisplay) { |
| 142 | this._displayObject.removeChild(childDisplay); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | this.setBoundsChangedFlag(); |
| 147 | |
| 148 | if (bDispose) { |
| 149 | child.dispose(); |
| 150 | } |
| 151 | |
| 152 | return child; |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Remove children in range |
no test coverage detected