I just tried your code and i keep getting the same error:

ArgumentError: Error #2015: Invalid BitmapData.
at flash.display::BitmapData$iinit()

so i am really confused now :-/ 

thank you very much for your time and help


Daniel Freiman wrote:
> 
>  var target:UIComponent = event.curentTarget as UIComponent;
> var dragProxy:UIComponent = new UIComponent();
> var w:Number = Math.round(target.width / target.scaleX); // will throw
> error
> if greater than 2880
> var h:Number = Math.round(target.height / target.scaleY) // will throw
> error
> if greater than 2880
> var bitmapData:BitmapData = new BitmapData(w,h);
> bitmapData.draw(target); // draw target into bitmap
> dragProxy.setActualSize(w,h);
> dragProxy.graphics.beginBitmapFill(bitmapData)
> dragProxy.graphics.drawRect(0, 0 ,w, h);  // draw bitmap onto proxy
> component.
> 
> Sorry this is taking so much back and forth.
> 
> - Dan Freiman
> 
> 
> On Nov 12, 2007 11:57 AM, Mirko Sabljić <[EMAIL PROTECTED]> wrote:
> 
>>
>> Still doesn't work, would it be too much to ask you to post that code to
>> draw
>> bitmap data onto UIComponent? I tried to implment that idea with
>> following
>> code:
>>
>> public function dragItMain(event:MouseEvent):void{
>>
>>
>> // Get the drag initiator component from the event object.
>> var dragInitiator:UIComponent = event.currentTarget as
>> UIComponent;
>>
>> // Create a DragSource object.
>> var dragSource:DragSource = new DragSource();
>> dragSource.addData(dragInitiator, "main");
>>
>> var target:UIComponent = event.curentTarget as UIComponent;
>> var bitmapData:BitmapData = new BitmapData(
>> Math.round(target.width /
>> target.scaleX),
>> Math.round(target.height /
>> target.scaleY),
>> false);
>> bitmapData.draw(target);
>>
>> var bitmap:Bitmap = new Bitmap(bitmapData);
>>
>> var bitmapHolder:UIComponent = new UIComponent();
>> bitmapHolder.addChild(bitmap);
>>
>> // Call the DragManager doDrag() method to start the drag.
>> DragManager.doDrag(dragInitiator, dragSource, event,
>> bitmapHolder);
>>
>> }
>>
>> But all i got is the following error:
>>
>> ArgumentError: Error #2015: Invalid BitmapData.
>> at flash.display::BitmapData$iinit()
>>
>>
>> Daniel Freiman wrote:
>> >
>> > Sorry, try BitmapAsset instead of Bitmap, which extends Bitmap and
>> > implements IFlexDisplayObject. If that doesn't work, I have code to
>> draw
>> > the bitmap data onto a UIComponent.
>> >
>> > - Dan Freiman
>> >
>> > On Nov 12, 2007 7:13 AM, Mirko Sabljić
>> <[EMAIL PROTECTED]<msabljic%40gmail.com>>
>> wrote:
>> >
>> >>
>> >> 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]
>> <msabljic%40gmail.com><msabljic%40gmail.com>>
>> >> 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.
>> >>
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Drag-and-drop-question-tf4786816.html#a13709369
>> Sent from the FlexCoders mailing list archive at Nabble.com.
>>
>>  
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Drag-and-drop-question-tf4786816.html#a13711153
Sent from the FlexCoders mailing list archive at Nabble.com.

Reply via email to