A Tile Container with draggable children : Tile « Container « Flex






A Tile Container with draggable children

A Tile Container with draggable children
         
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Tile width="300" height="600" direction="horizontal">
        <mx:Script>
            
                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<this.numChildren; i++)
                    {
                        if(this.getChildAt(i).hitTestObject(obj))
                        {
                            return getChildAt(i);
                        }
                    }
                    return getChildAt(0)
                }
    
    
          
        </mx:Script>
        <mx:Panel title="First Panel" mouseDown="childStartDrag(event)">
            <mx:Text text="First Text"/>
        </mx:Panel>
    </mx:Tile>
</mx:Application>

   
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Create horizontal Tile containerCreate horizontal Tile container
2.Use Tile control's tileWidth to specify the width of the tilesUse Tile control's tileWidth to specify the width of the tiles
3.Retrieve last child index in a Tile, child indices are zero-basedRetrieve last child index in a Tile, child indices are zero-based
4.Get reference to last child in a TileGet reference to last child in a Tile
5.Remove item from TileRemove item from Tile
6.Tile DemoTile Demo
7.Override layout to use TileLayoutOverride layout to use TileLayout
8.Create the horizontal Tile containerCreate the horizontal Tile container
9.Using Tile control's tileWidth property to specify the width of the tilesUsing Tile control's tileWidth property to specify the width of the tiles