* Set child index * 设置子显示对象的索引
(child: DisplayObject, index: number)
| 429 | * 设置子显示对象的索引 |
| 430 | */ |
| 431 | public setChildIndex(child: DisplayObject, index: number): void { |
| 432 | const currentIndex = this._children.indexOf(child); |
| 433 | if (currentIndex < 0) return; |
| 434 | |
| 435 | index = Math.max(0, Math.min(index, this._children.length - 1)); |
| 436 | if (currentIndex === index) return; |
| 437 | |
| 438 | this._children.splice(currentIndex, 1); |
| 439 | this._children.splice(index, 0, child); |
| 440 | } |
| 441 | |
| 442 | /** |
| 443 | * Swap two children |