I have a very (very) simple demo program that is listed below. I was
having trouble dropping a tilelist item onto a canvas. I was able to
get the drop to work only if I set the toolTip of the canvas. This
seems very odd, like the canvas was not initialized yet. The drag
operation starts OK enough but I get the cannot drop marker when I try
to drop on the canvas, UNLESS I set the tooltip to something. Any ideas?


Rich


------------------------------







<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute" creationComplete="onInit()">
        <mx:Script>
                <![CDATA[
                        import mx.utils.ObjectProxy;
                        import mx.collections.ArrayCollection;
                        import mx.core.DragSource;
            import mx.managers.DragManager;
            import mx.events.*;
                        
                    var anArrayCollection : ArrayCollection = new 
ArrayCollection();
                        private function onInit() : void {
                                
                                var thisItem : ObjectProxy = new ObjectProxy();
                                thisItem.title = "Item 1";
                                anArrayCollection.addItem(thisItem);
                                thisItem = new ObjectProxy();
                                thisItem.title = "Item 2";
                                anArrayCollection.addItem(thisItem);
                                tlTest.dataProvider = anArrayCollection;
                                
                                
cvsDropTarget.addEventListener(DragEvent.DRAG_ENTER,
onSpaceDragEnter);
                        cvsDropTarget.addEventListener(DragEvent.DRAG_DROP,
onSpaceDragDrop);                               
                                
                                
                        }
                        
            private function onSpaceDragEnter(event : DragEvent) : void {
                 var dropTarget: Canvas = Canvas(event.currentTarget);

                    // Accept the drag only if the user is dragging data 
                    // identified by the 'color' format value.
                    if (event.dragSource != null) {  
                        DragManager.acceptDragDrop(dropTarget);
                    }                           
                        }
                        
                    private function onSpaceDragDrop(event : DragEvent) : void {
                        var thisItem : SimpleThumbnail =  new SimpleThumbnail();
                        thisItem.lblName.text = "Test";
                        thisItem.x = event.localX;
                        thisItem.y = event.localY;
                        thisItem.width  = 200;
                        thisItem.height = 200;  
                        cvsDropTarget.addChild(thisItem);
                        
                    }
                        
                ]]>
        </mx:Script>
        <mx:Canvas id="cvsDropTarget"  x="0" y="0" width="100%" height="100%"
toolTip=" "/>
        <mx:TileList id="tlTest" x="0" y="0" width="140" height="100%"
itemRenderer="SimpleThumbnail" dragEnabled="true"
allowMultipleSelection="false" />
        
</mx:Application>



-----------------------------------
// Simple Thumbnail

<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"; width="120"
height="120"  
             verticalAlign="middle" cornerRadius="10" borderStyle="solid"
backgroundColor="#c0c0c0">
        <mx:Label text="{data.title}" id="lblName" fontSize="28"
textAlign="center" width="100%"/>
        
</mx:HBox>

Reply via email to