Container Flex


    
        
            
                import mx.core.UIComponent;
    
                private function childStartDrag(event:Event):void
                {
                    (event.currentTarget as UIComponent).startDrag(false, this.getBounds(stage));
                    (event.currentTarget as UIComponent).addEventListener(MouseEvent.MOUSE_DOWN, childStopDrag);
                    swapChildren((event.currentTarget as UIComponent), getChildAt(numChildren-1));
                }
    
                private function childStopDrag(event:Event):void
                {
                    swapChildren((event.currentTarget as UIComponent),hitTestChild((event.currentTarget as UIComponent)));
                    (event.currentTarget as UIComponent).stopDrag();
                    this.invalidateDisplayList();
                }
    
                private function hitTestChild(obj:UIComponent):DisplayObject
                {
                    for(var i:int = 0; i                    {
                        if(this.getChildAt(i).hitTestObject(obj))
                        {
                            return getChildAt(i);
                        }
                    }
                    return getChildAt(0)
                }