One thought is that the doc specifies to use a container as a drop
target, you must use the backgroundColor property of the container to
set a color. Otherwise, the background color of the container is
transparent, and the Drag and Drop Manager is unable to detect that the
mouse pointer is on a possible drop target. 
 
Stephen

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of richmcgillicuddy
Sent: Saturday, March 03, 2007 11:53 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Drag Drop Compiler Bug/Problem



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
<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
<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