* Add a child at specific index * 在指定位置添加子显示对象
(child: DisplayObject, index: number)
| 308 | * 在指定位置添加子显示对象 |
| 309 | */ |
| 310 | public addChildAt(child: DisplayObject, index: number): void { |
| 311 | if (child._parent === this) { |
| 312 | this.setChildIndex(child, index); |
| 313 | return; |
| 314 | } |
| 315 | |
| 316 | if (child._parent) { |
| 317 | child._parent.removeChild(child); |
| 318 | } |
| 319 | |
| 320 | index = Math.max(0, Math.min(index, this._children.length)); |
| 321 | this._children.splice(index, 0, child); |
| 322 | child._parent = this; |
| 323 | child.markTransformDirty(); |
| 324 | |
| 325 | // Dispatch addedToStage event if this is on stage |
| 326 | // 如果当前对象在舞台上,分发 addedToStage 事件 |
| 327 | if (this._stage !== null) { |
| 328 | this.setChildStage(child, this._stage); |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | /** |
| 333 | * Set stage for child and its descendants, dispatch events |
nothing calls this directly
no test coverage detected