I followed your advice Dan and used this code:
public function dragItSubs(event:MouseEvent):void{
// Get the drag initiator component from the event object.
var dragInitiator:UIComponent = event.currentTarget as UIComponent;
/////////////////////////////////////////////////////////
var target:UIComponent = event.currentTarget as UIComponent;
var dragProxy:Bitmap;
var myBitmapData:BitmapData = new BitmapData(target.width, target.height);
myBitmapData.draw(target); // draw target onto bitmap
dragProxy = new Bitmap(myBitmapData);
/////////////////////////////////////////////////////////
// Call the DragManager doDrag() method to start the drag.
DragManager.doDrag(dragInitiator, event, dragProxy);
}
But now i get the following error:
1067: Implicit coercion of a value of type flash.display:Bitmap to an
unrelated type mx.core:IFlexDisplayObject.
on line:
DragManager.doDrag(dragInitiator, event, dragProxy);
Do you maybe know how can i solve this?
thank you
Daniel Freiman wrote:
>
> Use a bitmap of the target instead of the original target.
>
> ///////////////////////////////////////////////
> var target:UIComponent = event.currentTarget as UIComponent;
> var dragProxy:Bitmap;
> var myBitmapData:BitmapData = new BitmapData(target.width, target.height);
> myBitmapData.draw(target); // draw target onto bitmap
> dragProxy = new Bitmap(myBitmapData);
> //////////////////////////////////////////////
>
> - Dan Freiman
>
> On Nov 11, 2007 12:57 PM, <[EMAIL PROTECTED]> wrote:
>
>> Hi,
>>
>> I am trying to drag an UIComponent instance over an Image object and
>> drag and drop work fine but i am having problem with dragProxy image.
>> I would like to use my original drag source UIComponent as dragProxy
>> image but if i do the following:
>>
>> public function dragItSubs(event:MouseEvent):void{
>>
>> // Get the drag initiator component from the event object.
>> var dragInitiator:UIComponent = event.currentTarget as UIComponent;
>>
>> /////////////////////////////////////////////////////////
>> var dragProxy:UIComponent = new UIComponent;
>> dragProxy = event.currentTarget as UIComponent;
>> /////////////////////////////////////////////////////////
>>
>> // Call the DragManager doDrag() method to start the drag.
>> DragManager.doDrag(dragInitiator, event, dragProxy);
>>
>> }
>>
>> then the original UIComponent (which is a drag source) is used as
>> dragProxy while dragging it but that same component dissapears from
>> its original position as soon as dragging starts. How can i accomplish
>> that drag source UIComponent's "image" is used as dragProxy but the
>> same source drag UIComponent is intact while dragging?
>>
>> thanks in advance
>>
>> --
>> Best regards,
>> Mirko mailto:msabljic[at]gmail.com
>>
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Drag-and-drop-question-tf4786816.html#a13704547
Sent from the FlexCoders mailing list archive at Nabble.com.