The List classes do something like that too, so that may be ok.

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Derrick Anderson
Sent: Monday, June 02, 2008 1:49 PM
To: [email protected]
Subject: Re: [flexcoders] dragging tree item to canvas- the drag proxy
location is off

 

yes i did, it still was not right- meant to delete that offsetY
variable.

i just put this hack in and it's working well, i'd like to know how this
is supposed to be done- i'm sure dragging from a tree is common, even
with using a custom dragStart function.

// Create a filterItem to use as a drag proxy.
                var dragProxy:filterItem = new filterItem();
                dragProxy.properties = item;
                dragProxy.width = 500;
                dragProxy.x = event.localX;
                dragProxy.y = event.localY;
                // Call the DragManager doDrag() method to start the
drag. 
                DragManager.doDrag(dragInitiator, dragSource, event,
dragProxy);

On Mon, Jun 2, 2008 at 4:37 PM, Alex Harui <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote:

Did you try:

 

                DragManager.doDrag(dragInitiator, dragSource, event,
dragProxy, offsetX, offsetY);

________________________________

From: [email protected] <mailto:[email protected]>
[mailto:[email protected] <mailto:[email protected]> ]
On Behalf Of Derrick Anderson
Sent: Monday, June 02, 2008 1:33 PM
To: [email protected] <mailto:[email protected]> 
Subject: [flexcoders] dragging tree item to canvas- the drag proxy
location is off

 

i am using the script below on my 'dragStart' handler of a tree.  the
problem is the drag proxy i'm passing to DragManager.doDrag looks fine
on screen except for it's position is equal to that of the source tree,
not my mouse pointer.  how do i get the drag proxy to sync up location
with my mouse?


private function dragIt(event:MouseEvent):void 
            {
                // Get the drag initiator component from the event
object.
                var dragInitiator:Tree = event.currentTarget as Tree;
                
                // Create a DragSource object.
                var dragSource:DragSource = new DragSource();
                
                var item:XML = event.target.selectedItem;
                // Add the data to the object.
                dragSource.addData(item,'properties');
    
                // Create a filterItem to use as a drag proxy.
                var dragProxy:filterItem = new filterItem();
                dragProxy.properties = item;
                dragProxy.width = 500;
                // the drag initiator is seen as the list, not the list
item-
                // so i need to offset the drag proxy Y to match the
mouseY
                // so that the drag proxy stays underneath the mouse
                var offsetY:Number = dragInitiator.y + event.localY;
                // Call the DragManager doDrag() method to start the
drag. 
                DragManager.doDrag(dragInitiator, dragSource, event,
dragProxy);
            }

 

 

Reply via email to