# Drag and child index

**URL:** <https://forum.kirupa.com/t/drag-and-child-index/293983>\
**Category:** Uncategorized\
**Created:** [August 6, 2009, 1:03pm UTC](https://forum.kirupa.com/t/drag-and-child-index/293983 "2009-08-06T13:03:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lope](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@lope](https://forum.kirupa.com/u/lope)\
**Post date:** [August 6, 2009, 1:03pm UTC](https://forum.kirupa.com/t/drag-and-child-index/293983/1 "2009-08-06T13:03:57Z")

</div>

**I have 2 sprites on stage each containing some children…**

function startDragCard(e:MouseEvent):void {

**//would it be possible to write this line so that it “accepts” drag child from any of two sprites so that I dont have to separate my code?**  
thumbSprite.setChildIndex(e.target as DisplayObject, thumbSprite.numChildren - 1);  
**//or**  
centerSprite.setChildIndex(e.target as DisplayObject, centerSprite.numChildren - 1);

* * *

edit:  
I think I found the answer myself…

e.target.parent.setChildIndex(e.target as DisplayObject, e.target.parent.numChildren - 1);
