Re: [flexcoders] Flex 2.0 Beta3 | Getting data from DragSource Object

2006-06-07 Thread Tom Chiverton
On Monday 05 June 2006 18:27, Dennis Riedel wrote:
 What I want to get now is the data within this DragSource object from
 the item I am dragging. The documentation (LiveDocs) says something
 about an IDataProvider Interface but I cannot find it anywhere in the
 LiveDocs.

I built last week a thing that had drag/drop panels.
The way outlined in the Flex docs is that you store the data you want to pass 
on in the drag object (dragSource).

I've attached the sample code from the docs.

-- 
Tom Chiverton




This email is sent for and on behalf of Halliwells LLP.

Halliwells LLP is a limited liability partnership registered in England and 
Wales under registered number OC307980 whose registered office address is at St 
James's Court Brown Street Manchester M2 2JF.  A list of members is available 
for inspection at the registered office. Any reference to a partner in relation 
to Halliwells LLP means a member of Halliwells LLP. Regulated by the Law 
Society.

CONFIDENTIALITY

This email is intended only for the use of the addressee named above and may be 
confidential or legally privileged.  If you are not the addressee you must not 
read it and must not use any information contained in nor copy it nor inform 
any person other than Halliwells LLP or the addressee of its existence or 
contents.  If you have received this email in error please delete it and notify 
Halliwells LLP IT Department on 0870 365 8008.

For more information about Halliwells LLP visit www.halliwells.com.

We are pleased to announce that Halliwells LLP has been voted AIM Lawyer of the 
Year at the 2005 Growth Company Awards


 Yahoo! Groups Sponsor ~-- 
Protect your PC from spy ware with award winning anti spy technology. It's free.
http://us.click.yahoo.com/97bhrC/LGxNAA/yQLSAA/nhFolB/TM
~- 

--
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/

* 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/
 
?xml version=1.0?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;

mx:Script
![CDATA[
import mx.core.DragSource;
import mx.managers.DragManager;
import mx.events.*;
import mx.containers.Canvas;

// Called when the user clicks the mouse on either colored canvas.
// Initializes the drag.
private function dragIt(event:MouseEvent, text:String,
format:String):void {
// Get the drag initiator component from the event object.
var dragInitiator:Canvas=Canvas(event.currentTarget);
// Create a DragSource object.
var ds:DragSource = new DragSource();
// Add the data to the object.
ds.addData(text, format);

// Create a Canvas container to use as the drag proxy.
// You must specify a size for the proxy image, 
// or else it will not appear.
var canvasProxy:Canvas = new Canvas();
canvasProxy.width=30;
canvasProxy.height=30;
canvasProxy.setStyle('backgroundColor',
dragInitiator.getStyle('backgroundColor'));

// Call the DragManager doDrag() method to start the drag. 
// For information on this method, see 
// the Initiating the drag section.
DragManager.doDrag(dragInitiator, ds, event, canvasProxy);
}

// Called if the user dragged a proxy onto the drop target canvas.
private function doDragEnter(event:DragEvent):void {
// Get the drop target component from the event object.
var dropTarget:Canvas=Canvas(event.currentTarget);

// Accept the drag only if the user is dragging data 
// identified by the 'color' format value.
if (event.dragSource.hasFormat('color')) {
DragManager.acceptDragDrop(dropTarget);
}
}

// Called if the target accepts the dragged object and the user 
// releases the mouse button while over the canvas. 
// Handles the dragDrop event for the List control.
private function doDragDrop(event:DragEvent):void {
// Get the data identified by the color format from the drag source.
var data:Object = event.dragSource.dataForFormat('color');
// Set the canvas color.
myCanvas.setStyle(backgroundColor, data);
}

]]
/mx:Script

!-- A horizontal box with red and green canvases the user can drag --
mx:HBox
mx:Canvas 

[flexcoders] Flex 2.0 Beta3 | Getting data from DragSource Object

2006-06-05 Thread Dennis Riedel



Hello

I tried out to drag and drop an item from one DataGrid component to
another DataGrid component. That works really fine.
But I do not want to have a second DataGrid but a custom component which
displays the data that is dropped into it in another form.

For testing purposes I´ve set for the second DataGrid (the dropTarget)
the function for dragEnter and wrote an Event Handler Function.
In this function I access the event object DragEvent and get the
DragSource object.

What I want to get now is the data within this DragSource object from
the item I am dragging. The documentation (LiveDocs) says something
about an IDataProvider Interface but I cannot find it anywhere in the
LiveDocs.

Normally I guess I would access the data when the item was dropped
through my container component. But I just want to access the data of
the dragged item before I create a new graphical representation/widget
with the data in it. So I want to get the data within my Drop Event
Handler function. I thought I can do this through this DragSource
object...

Thanks for any suggestions on this.

Dennis






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

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.