[flexcoders] Drag and Drop question

2010-09-05 Thread Christophe
Hello, 

How to Drag an Image A on the Image B. 

The image A replace the image B.
And the image B come to replace the image A automatically. (There is a 
swapping).

I use DragDropHandler and dragEnterHandler. 

Thank you,
Christophe, 




[flexcoders] Drag and Drop question

2008-09-16 Thread zootpeet
I am trying to implement drag and drop onto a tree. In the dropDrop
handler, I want to be able to deny the drop from happening, based on
which element of the tree is being dropped on. 

  // r is the visible index in the tree
  var dropTarget:Tree = Tree(event.currentTarget);
  var r:int = dropTarget.calculateDropIndex(event);
  dstXmlTree.selectedIndex = r;
  var node:XML = dstXmlTree.selectedItem as XML;

  if (node.toXMLSting == whatever) {
 // Allow drop  -- HOW?
  } else {
 // Do NOT allow drop  -- HOW?
  }

How do I deny the drop?

thanks!

   





Re: [flexcoders] Drag and Drop question

2008-09-16 Thread Pan Troglodytes
I believe you're going to need to handle the drop events yourself and not
use the dropEnabled=true setting.  When you do that, by default drop is
denied and you have to tell it to allow it, like in the dragEnter event.
For example:

private function dragEnterHandler(e:DragEvent):void
{
  DragManager.acceptDragDrop(UIComponent(e.currentTarget));
  DragManager.showFeedback(DragManager.COPY);
}


On Tue, Sep 16, 2008 at 9:59 AM, zootpeet [EMAIL PROTECTED] wrote:

   I am trying to implement drag and drop onto a tree. In the dropDrop
 handler, I want to be able to deny the drop from happening, based on
 which element of the tree is being dropped on.

 // r is the visible index in the tree
 var dropTarget:Tree = Tree(event.currentTarget);
 var r:int = dropTarget.calculateDropIndex(event);
 dstXmlTree.selectedIndex = r;
 var node:XML = dstXmlTree.selectedItem as XML;

 if (node.toXMLSting == whatever) {
 // Allow drop -- HOW?
 } else {
 // Do NOT allow drop -- HOW?
 }

 How do I deny the drop?

 thanks!

  




-- 
Jason


RE: [flexcoders] Drag and Drop question

2008-09-16 Thread Tracy Spratt
I use the dropEnabled setting, but in all of the handlers, I call
event.preventDefault();  Then I test the source and target and call
DragManager.showFeedback(), DragManager.acceptDragDrop() conditionally
as required.

 

Tracy

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Pan Troglodytes
Sent: Tuesday, September 16, 2008 11:20 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Drag and Drop question

 

I believe you're going to need to handle the drop events yourself and
not use the dropEnabled=true setting.  When you do that, by default drop
is denied and you have to tell it to allow it, like in the dragEnter
event.  For example:

private function dragEnterHandler(e:DragEvent):void
{
  DragManager.acceptDragDrop(UIComponent(e.currentTarget));
  DragManager.showFeedback(DragManager.COPY);
}



On Tue, Sep 16, 2008 at 9:59 AM, zootpeet [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]  wrote:

I am trying to implement drag and drop onto a tree. In the dropDrop
handler, I want to be able to deny the drop from happening, based on
which element of the tree is being dropped on. 

// r is the visible index in the tree
var dropTarget:Tree = Tree(event.currentTarget);
var r:int = dropTarget.calculateDropIndex(event);
dstXmlTree.selectedIndex = r;
var node:XML = dstXmlTree.selectedItem as XML;

if (node.toXMLSting == whatever) {
// Allow drop -- HOW?
} else {
// Do NOT allow drop -- HOW?
}

How do I deny the drop?

thanks!




-- 
Jason

 



[flexcoders] Drag and Drop question

2008-05-01 Thread Rafael Faria
If i'm dragging an element from one tree to another. How do i get the
updated xml of the tree i'm dragging off?

For instance

TREE 1
 - Element 1
 - Element 2


TREE 2



if i get the xml from tree 1 it would be something like
root
   element label=Element 1 /
   element label=Element 2 /
/root

but if i drag the Element 1 into the TREE 2 i want to get the xml
without the Element 1, without that node.

i'm trying to get it creating a handler for dragDrop attribute on
the Tree 2, but everytime i get it the items are not updated.

Anyone know how to get the updated xml that tree 1 will have after i
drop the element?

Please... this is killing me =/

Thanks




Re: [flexcoders] Drag and Drop question

2008-05-01 Thread Josh McDonald
I'm fairly certain that there's no voodoo to automatically delete nodes from
your XML, you need to do that yourself in your drop handler.

-J

On Thu, May 1, 2008 at 4:36 PM, Rafael Faria [EMAIL PROTECTED]
wrote:

   If i'm dragging an element from one tree to another. How do i get the
 updated xml of the tree i'm dragging off?

 For instance

 TREE 1
 - Element 1
 - Element 2

 TREE 2

 if i get the xml from tree 1 it would be something like
 root
 element label=Element 1 /
 element label=Element 2 /
 /root

 but if i drag the Element 1 into the TREE 2 i want to get the xml
 without the Element 1, without that node.

 i'm trying to get it creating a handler for dragDrop attribute on
 the Tree 2, but everytime i get it the items are not updated.

 Anyone know how to get the updated xml that tree 1 will have after i
 drop the element?

 Please... this is killing me =/

 Thanks

  




-- 
Therefore, send not to know For whom the bell tolls. It tolls for thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]


RE: [flexcoders] Drag and Drop question

2008-05-01 Thread Tracy Spratt
Actually I am pretty sure the list-based component's built-in drag/drop
functionality does do this on a MOVE.  The docs describe this.  Are the
XML structures the same?

 

Tracy

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Josh McDonald
Sent: Thursday, May 01, 2008 2:46 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Drag and Drop question

 

I'm fairly certain that there's no voodoo to automatically delete nodes
from your XML, you need to do that yourself in your drop handler.

-J

On Thu, May 1, 2008 at 4:36 PM, Rafael Faria
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
wrote:

If i'm dragging an element from one tree to another. How do i get the
updated xml of the tree i'm dragging off?

For instance

TREE 1
- Element 1
- Element 2

TREE 2

if i get the xml from tree 1 it would be something like
root
element label=Element 1 /
element label=Element 2 /
/root

but if i drag the Element 1 into the TREE 2 i want to get the xml
without the Element 1, without that node.

i'm trying to get it creating a handler for dragDrop attribute on
the Tree 2, but everytime i get it the items are not updated.

Anyone know how to get the updated xml that tree 1 will have after i
drop the element?

Please... this is killing me =/

Thanks




-- 
Therefore, send not to know For whom the bell tolls. It tolls for
thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]  

 



Re: [flexcoders] Drag and Drop question

2008-05-01 Thread Josh McDonald
How do you mark a drag/drop operation as having a certain type (ie Move)?

-J

On Fri, May 2, 2008 at 5:32 AM, Tracy Spratt [EMAIL PROTECTED] wrote:

Actually I am pretty sure the list-based component's built-in drag/drop
 functionality does do this on a MOVE.  The docs describe this.  Are the XML
 structures the same?



 Tracy


  --

 *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
 Behalf Of *Josh McDonald
 *Sent:* Thursday, May 01, 2008 2:46 AM
 *To:* flexcoders@yahoogroups.com
 *Subject:* Re: [flexcoders] Drag and Drop question



 I'm fairly certain that there's no voodoo to automatically delete nodes
 from your XML, you need to do that yourself in your drop handler.

 -J

 On Thu, May 1, 2008 at 4:36 PM, Rafael Faria [EMAIL PROTECTED]
 wrote:

 If i'm dragging an element from one tree to another. How do i get the
 updated xml of the tree i'm dragging off?

 For instance

 TREE 1
 - Element 1
 - Element 2

 TREE 2

 if i get the xml from tree 1 it would be something like
 root
 element label=Element 1 /
 element label=Element 2 /
 /root

 but if i drag the Element 1 into the TREE 2 i want to get the xml
 without the Element 1, without that node.

 i'm trying to get it creating a handler for dragDrop attribute on
 the Tree 2, but everytime i get it the items are not updated.

 Anyone know how to get the updated xml that tree 1 will have after i
 drop the element?

 Please... this is killing me =/

 Thanks




 --
 Therefore, send not to know For whom the bell tolls. It tolls for thee.

 :: Josh 'G-Funk' McDonald
 :: 0437 221 380 :: [EMAIL PROTECTED]

  




-- 
Therefore, send not to know For whom the bell tolls. It tolls for thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]


RE: [flexcoders] Drag and Drop question

2008-05-01 Thread Tracy Spratt
Move is the default, there is extra work to copy.

 

http://livedocs.adobe.com/flex/3/html/dragdrop_8.html

Tracy

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Josh McDonald
Sent: Thursday, May 01, 2008 5:05 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Drag and Drop question

 

How do you mark a drag/drop operation as having a certain type (ie
Move)?

-J

On Fri, May 2, 2008 at 5:32 AM, Tracy Spratt [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]  wrote:

Actually I am pretty sure the list-based component's built-in drag/drop
functionality does do this on a MOVE.  The docs describe this.  Are the
XML structures the same?

 

Tracy

 



From: flexcoders@yahoogroups.com mailto:flexcoders@yahoogroups.com
[mailto:flexcoders@yahoogroups.com mailto:flexcoders@yahoogroups.com ]
On Behalf Of Josh McDonald
Sent: Thursday, May 01, 2008 2:46 AM
To: flexcoders@yahoogroups.com mailto:flexcoders@yahoogroups.com 
Subject: Re: [flexcoders] Drag and Drop question

 

I'm fairly certain that there's no voodoo to automatically delete nodes
from your XML, you need to do that yourself in your drop handler.

-J

On Thu, May 1, 2008 at 4:36 PM, Rafael Faria
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
wrote:

If i'm dragging an element from one tree to another. How do i get the
updated xml of the tree i'm dragging off?

For instance

TREE 1
- Element 1
- Element 2

TREE 2

if i get the xml from tree 1 it would be something like
root
element label=Element 1 /
element label=Element 2 /
/root

but if i drag the Element 1 into the TREE 2 i want to get the xml
without the Element 1, without that node.

i'm trying to get it creating a handler for dragDrop attribute on
the Tree 2, but everytime i get it the items are not updated.

Anyone know how to get the updated xml that tree 1 will have after i
drop the element?

Please... this is killing me =/

Thanks







-- 
Therefore, send not to know For whom the bell tolls. It tolls for
thee.

:: Josh 'G-Funk' McDonald

:: 0437 221 380 :: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]  




-- 
Therefore, send not to know For whom the bell tolls. It tolls for
thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]  

 



Re: [flexcoders] Drag and Drop question

2008-05-01 Thread Josh McDonald
Ew =)

All my dragdrop stuff is funky custom components so I never noticed. But ew.

-J

On Fri, May 2, 2008 at 7:49 AM, Tracy Spratt [EMAIL PROTECTED] wrote:

Move is the default, there is extra work to copy.



 http://livedocs.adobe.com/flex/3/html/dragdrop_8.html

 Tracy


  --

 *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
 Behalf Of *Josh McDonald
 *Sent:* Thursday, May 01, 2008 5:05 PM

 *To:* flexcoders@yahoogroups.com
 *Subject:* Re: [flexcoders] Drag and Drop question



 How do you mark a drag/drop operation as having a certain type (ie Move)?

 -J

 On Fri, May 2, 2008 at 5:32 AM, Tracy Spratt [EMAIL PROTECTED]
 wrote:

 Actually I am pretty sure the list-based component's built-in drag/drop
 functionality does do this on a MOVE.  The docs describe this.  Are the XML
 structures the same?



 Tracy


  --

 *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
 Behalf Of *Josh McDonald
 *Sent:* Thursday, May 01, 2008 2:46 AM
 *To:* flexcoders@yahoogroups.com
 *Subject:* Re: [flexcoders] Drag and Drop question



 I'm fairly certain that there's no voodoo to automatically delete nodes
 from your XML, you need to do that yourself in your drop handler.

 -J

 On Thu, May 1, 2008 at 4:36 PM, Rafael Faria [EMAIL PROTECTED]
 wrote:

 If i'm dragging an element from one tree to another. How do i get the
 updated xml of the tree i'm dragging off?

 For instance

 TREE 1
 - Element 1
 - Element 2

 TREE 2

 if i get the xml from tree 1 it would be something like
 root
 element label=Element 1 /
 element label=Element 2 /
 /root

 but if i drag the Element 1 into the TREE 2 i want to get the xml
 without the Element 1, without that node.

 i'm trying to get it creating a handler for dragDrop attribute on
 the Tree 2, but everytime i get it the items are not updated.

 Anyone know how to get the updated xml that tree 1 will have after i
 drop the element?

 Please... this is killing me =/

 Thanks





 --
 Therefore, send not to know For whom the bell tolls. It tolls for thee.

 :: Josh 'G-Funk' McDonald

 :: 0437 221 380 :: [EMAIL PROTECTED]




 --
 Therefore, send not to know For whom the bell tolls. It tolls for thee.

 :: Josh 'G-Funk' McDonald
 :: 0437 221 380 :: [EMAIL PROTECTED]

  




-- 
Therefore, send not to know For whom the bell tolls. It tolls for thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]


RE: [flexcoders] Drag And Drop Question: List within list...

2007-12-17 Thread Alex Harui
Tree is buggy in Flex 2.  If you can, get on the beta for Flex 3 and see
if you still have problems there.



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Boson Au
Sent: Thursday, December 06, 2007 10:40 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Drag And Drop Question: List within list...



Hi everyone, I'm a beginning Flex Developer, but I've had a couple of
years experience w/ scripting.

here's my problem:

my current app basically deals with folders and files, such that a
folder has files and a folder can have another folder (that has files
or other folders... you get the idea) 

I'm populating this using a really simple xml list of nodes and
children.

I'm using a tree control with DnD enabled. I've been testing this and
here's what's going on:

1.) I drag the files and folders around on the own 'level' and reorder
them: all good.
2.) I drag a file from one folder and put them in another, this is
where it gets weird. It either does not remove the original object
being dragged from its previous list, or it disappears into the ether
and I just straight up lose the object.

can anyone help? I uploaded the test at
http://www.americanforkliftsociety.com/flexStuff/xmlTest.html
http://www.americanforkliftsociety.com/flexStuff/xmlTest.html  (rt
click to view source)...



 


RE: [flexcoders] Drag And Drop Question: List within list...

2007-12-17 Thread Alex Harui
Actually, it turns out you hit the array-of-one problem described here:
http://blogs.adobe.com/aharui/2007/03/arraycollection_arrays_and_ser.htm
l
 
Node  only has one child and won't be converted properly.



From: Alex Harui 
Sent: Monday, December 17, 2007 12:03 PM
To: 'flexcoders@yahoogroups.com'
Subject: RE: [flexcoders] Drag And Drop Question: List within list...


Tree is buggy in Flex 2.  If you can, get on the beta for Flex 3 and see
if you still have problems there.



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Boson Au
Sent: Thursday, December 06, 2007 10:40 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Drag And Drop Question: List within list...



Hi everyone, I'm a beginning Flex Developer, but I've had a couple of
years experience w/ scripting.

here's my problem:

my current app basically deals with folders and files, such that a
folder has files and a folder can have another folder (that has files
or other folders... you get the idea) 

I'm populating this using a really simple xml list of nodes and
children.

I'm using a tree control with DnD enabled. I've been testing this and
here's what's going on:

1.) I drag the files and folders around on the own 'level' and reorder
them: all good.
2.) I drag a file from one folder and put them in another, this is
where it gets weird. It either does not remove the original object
being dragged from its previous list, or it disappears into the ether
and I just straight up lose the object.

can anyone help? I uploaded the test at
http://www.americanforkliftsociety.com/flexStuff/xmlTest.html
http://www.americanforkliftsociety.com/flexStuff/xmlTest.html  (rt
click to view source)...



 


[flexcoders] Drag And Drop Question: List within list...

2007-12-06 Thread Boson Au
Hi everyone, I'm a beginning Flex Developer, but I've had a couple of
years experience w/ scripting.

here's my problem:

my current app basically deals with folders and files, such that a
folder has files and a folder can have another folder (that has files
or other folders... you get the idea) 

I'm populating this using a really simple xml list of nodes and children.

I'm using a tree control with DnD enabled.  I've been testing this and
here's what's going on:


1.) I drag the files and folders around on the own 'level' and reorder
them: all good.
2.) I drag a file from one folder and put them in another, this is
where it gets weird.  It either does not remove the original object
being dragged from its previous list, or it disappears into the ether
and I just straight up lose the object.


can anyone help?  I uploaded the test at
http://www.americanforkliftsociety.com/flexStuff/xmlTest.html (rt
click to view source)...





Re: [flexcoders] Drag and drop question

2007-11-12 Thread Mirko Sabljić

Thank you very much for your help, i'll try that and let you know how did it
go.

best regards


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#a13702904
Sent from the FlexCoders mailing list archive at Nabble.com.



Re: [flexcoders] Drag and drop question

2007-11-12 Thread Mirko Sabljić

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.



Re: [flexcoders] Drag and drop question

2007-11-12 Thread Daniel Freiman
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] 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
 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.

  



Re: [flexcoders] Drag and drop question

2007-11-12 Thread Mirko Sabljić

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] 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
 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.



Re: [flexcoders] Drag and drop question

2007-11-12 Thread Daniel Freiman
 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.commsabljic%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
  
  
  
  
  
 
  

Re: [flexcoders] Drag and drop question

2007-11-12 Thread Mirko Sabljić

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.commsabljic%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 

Re: [flexcoders] Drag and drop question

2007-11-12 Thread Daniel Freiman
Are you trying to instantiate a bitmap that has a width or hight greater
than 2880?

- Dan Freiman

On Nov 12, 2007 1:23 PM, Mirko Sabljić [EMAIL PROTECTED] wrote:


 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]msabljic%40gmail.com
 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.commsabljic%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.commsabljic%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 

Re: [flexcoders] Drag and drop question

2007-11-12 Thread Mirko Sabljić

Definitely not, width and height of the image is under 1000px so i guess
that's not the problem?


Daniel Freiman wrote:
 
 Are you trying to instantiate a bitmap that has a width or hight greater
 than 2880?
 
 - Dan Freiman
 
 On Nov 12, 2007 1:23 PM, Mirko Sabljić [EMAIL PROTECTED] wrote:
 

 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]msabljic%40gmail.com
 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.commsabljic%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.commsabljic%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;
   

Re: [flexcoders] Drag and drop question

2007-11-12 Thread Daniel Freiman
Which line is is breaking on?  What's the stack trace look like?

- Dan Freiman

On Nov 12, 2007 3:48 PM, Mirko Sabljić [EMAIL PROTECTED] wrote:


 Definitely not, width and height of the image is under 1000px so i guess
 that's not the problem?


 Daniel Freiman wrote:
 
  Are you trying to instantiate a bitmap that has a width or hight greater
  than 2880?
 
  - Dan Freiman
 
  On Nov 12, 2007 1:23 PM, Mirko Sabljić [EMAIL 
  PROTECTED]msabljic%40gmail.com
 wrote:
 
 
  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] msabljic%40gmail.commsabljic%40gmail.com

  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.commsabljic%40gmail.commsabljic%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:Bitmapto
  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.commsabljic%40gmail.com
   msabljic%40gmail.commsabljic%40gmail.com
 
wrote:

 Hi,

 I am trying to drag an UIComponent instance over an Image
 object
   

[flexcoders] Drag and drop question

2007-11-11 Thread msabljic
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



Re: [flexcoders] Drag and drop question

2007-11-11 Thread Daniel Freiman
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

  



Re: [flexcoders] Drag-and-drop question

2005-02-12 Thread Manish Jethani
Pilby wrote:
Does Flex's drag-and-drop support dropping of mx:Button or mx:Text 
objects into a container like a mx:VBox? Or am I limited to dragging 
only items from a Tree, a List, or a datagrid?
You can drag-drop anything.
var dragItems = event.dragSource.dataForFormat(items);
and dragItems is always returning undefined.
Where are you adding the items to the DataSource?
You should be having something like this when the drag starts:
var ds:DragSource = new DragSource();
ds.addData([button, text], items);
DragManager.doDrag(this, ds, MyDragProxy);
Now dataForFormat(items) will return the button and text objects.
Manish