Thanks Derrick - that helped.  So essentially, you are using startDrag/stopDrag along doDrag() to accomplish a simple movement

That's what I was really wondering ;)  Thanks Derrick, this really helped,

JPG

On 10/18/06, Derrick Grigg <[EMAIL PROTECTED]> wrote:

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




--
[  JPG  ] __._,_.___

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





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to