The DragManager's purpose is to allow drag/drop
functionality for moving data around, not for just
moving components from place to place. That is
probably why you are having such a time with it. The
DragManager use's a DragProxy which is basically a
snapshot of what you want to move/drag, but it is not
the original you are moving.

Here's a quick sample that will let you drag the
original component (a small red box) around and drop
it onto two seperate canvases. Whichever canvas gets
dropped onto changes to green. Hope this helps
you out.

<?xml version="1.0" ?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute" creationComplete="init();">
    <mx:Script>
        <![CDATA[
            import mx.core.IFlexDisplayObject;
            import mx.core.UIComponent;
            import flash.events.MouseEvent;
            
            private var curParent: UIComponent;
            private var app: UIComponent 
            
            private function init()
            {
                app =
UIComponent(Application.application);
            }

            private function
handleStartDrag(event:MouseEvent):void
            {
                var target: UIComponent =
UIComponent(event.target);
                
                //remove the target from whatever parent
it is in
                curParent  = UIComponent(target.parent);
                curParent.removeChild(target);
                
                var p:Point = new Point(target.x,
target.y);
                p = curParent.localToGlobal(p);
                                //adjust the x/y to the main app coordinates
                target.x = p.x;
                target.y = p.y;
                
                //add target to the main root to avoid
depth problems
                app.addChild(target);
                
                        target.startDrag(false);

            } 
            
            private function
handleStopDrag(event:MouseEvent):void
            {
                //need to check against dropTarget.parent
because it is
picking up the border
                var dropTarget: UIComponent =
UIComponent(event.target.dropTarget.parent);
                var target: UIComponent =
UIComponent(event.target);

                if (curParent == box1_cv || curParent ==
box2_cv){
                        curParent.setStyle('backgroundColor',
'#CCCCCC');
                }
                
                if (dropTarget == box1_cv || dropTarget
== box2_cv){
                        dropTarget.setStyle('backgroundColor',
'#00ff00');
                }

                        //remove from application root
                        app.removeChild(target);

                var p:Point = new Point(target.x,
target.y);
                        p = app.localToGlobal(p);

                                //adjust the x/y to the main app coordinates
                        target.x = p.x - dropTarget.x;
                target.y = p.y - dropTarget.y;
                                
                        dropTarget.addChild(target);    

                target.stopDrag();
                
            }

   
        ]]>
    </mx:Script>
    
    <!-- Canvas drop target --> 
    <mx:Canvas id="box1_cv" 
        backgroundColor="#CCCCCC"
        width="100" 
        height="100" />
    <!-- Canvas drop target --> 
    <mx:Canvas id="box2_cv" 
        backgroundColor="#CCCCCC"
        width="100" 
        height="100"
        x="400" />
    
    <!-- The canvas being dragged -->
    <mx:Canvas id="drag_cv" 
        backgroundColor="#ff0000" 
        height="50" 
        width="50" 
        x="200" 
        y="200" 
        mouseDown="handleStartDrag(event);" 
        mouseUp="handleStopDrag(event);"/> 
    
</mx:Application>

Good luck

Derrick

--------------------------
Derrick Grigg
[EMAIL PROTECTED]
www.dgrigg.com


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to