Drag and drop custom component

I have a custom component that is a JPanel with a JTextField and a JButton. The component is a display and chooser for an address. I want to be able to copy the address from one to another with drag and drop.
Here's what I have so far. The drag starts, but it won't allow to drop on another instance of the same class. MyTransferHandler is a simple subclass of TransferHandler that logs everything so I can watch what is happening. The canImport() method of TransferHandler is never getting called. Any ideas?
transferHandler = new MyTransferHandler("address");
setTransferHandler(transferHandler);
dragListener = new MouseMotionListener() {
public void mouseDragged(MouseEvent a_evt) {
if (address != null) {
TransferHandler l_h = getTransferHandler();
l_h.exportAsDrag(PanelAddress.this, a_evt, TransferHandler.COPY);
public void mouseMoved(MouseEvent e) {
addMouseMotionListener(dragListener);
txtAddress.addMouseMotionListener(dragListener);

Figured it out while creating the SSCCE. Needed to set the TransferHandler on the text field and button because they were "hiding" the panel.
{noformat} MyTransferHandler l_transfer_handler = new MyTransferHandler("address");{noformat}{noformat} setTransferHandler(l_transfer_handler);{noformat}{noformat} txtAddress.setTransferHandler(l_transfer_handler);{noformat}{noformat} btnChoose.setTransferHandler(l_transfer_handler);{noformat}{noformat}{noformat}

Similar Messages

  • Firefox crashes after dragging and dropping any component.

    When the TorButton add-on is enabled, Firefox will crash when an attempt is made to drag and drop any component. This includes tabs, text, images, and any other item drag-and-drop-able under normal circumstances.
    This is a known bug and info lives at https://bugzilla.mozilla.org/show_bug.cgi?id=715885 but I don't know if any fix has been found.
    I am running version 3.6 of Firefox, which I recognize is rather out of date. This is because I have yet to update from OS X 10.4.
    Thank you for any input you have.

    It looks like the patch for this crash hasn't been checked in, and unfortunately, since firefox 3.6.28 is the last planned update for 3.6, it doesn't look like it will ever be fixed on that branch :(

  • Drag and drop custom object

    Hello,
    I am trying to create a GUI where the user will be able to drag an object (which I have created) from a toolbar button onto a JPanel. I have tried the sun tutorials to no avail. I am unsure exactly what code I should be writing to enable this functionality. I have written a dragmouseadapter which enables drag and drop from the button. I have also written a TransferHandler and Transferable for the object, but again I'm not sure how I should be using these. Can anyone advise me? Hopefully in a sort of step-by-step instruction for setting this up. Thank you.

    You wanted to drag and drop a custom component and you said its done using dragmouseadapter!
    TransferHandler and Transferable are used to transfer the data between the swing components.
    Now, what you want to do? So, we can help!

  • Drag and Drop custom objects

    Hi guys.
    I just finished reading the Java tutorial on Drag and Drop at http://download.oracle.com/javase/tutorial/uiswing/dnd/index.html.
    Unfortunately, there is no note about how to drag and drop a custon object. There is something said on DataFlavor, but not enough to help me.
    So I would appreciate it if anyone could tell me the steps to follow when dragging and droping a custom object.
    Best regards.
    Edmond

    I think we can help you, but please post some example/code of what you are trying to achieve.
    I made D&D with custom objects, custom icons, etc. and is not so hard ... like I said, post some code ...
    RGV

  • Drag and Drop List Component?

    Does anyone know how to use the v2 list component to let a
    user drag items from one list to another?
    Thanks in advance.

    No one knows of a tutorial for this?

  • Drag and Drop, dropping to a parent component.

    I've been searching high and low for a solution to a problem without any success. I'm hoping someone here might have a suggestion.
    I have an application (written using Java 5.0) which allows dragging and dropping custom components between JPanels. My components themselves are JPanels with other components in them such as JTextFields. I've written custom TransferHandlers for my components and all works well. If I drag one of my components and drop it on the receiving panel, it works. If I drag and drop on an existing one of my components, the drop works since the components themselves don't support dropping (the drop is accepted by the parent JPanel).
    My problem occurs when I inadvertently do a drop onto a text component within one of my components. In this case the drop is rejected since the text component doesn't accept my Transferable. What I would like to happen is have the drop passed up to a containing panel that does accept the Transferable.
    I can't disable drop on the text components as I'd like them to still accept string drops.
    Is there another solution that will allow a parent (or more generally an ancestor) of a component to accept a drop rejected by a child component?

    "bmilesp" <[email protected]> wrote in
    message
    news:gnd5c7$jas$[email protected]..
    > hello,
    >
    > I've been searching on how to add drag and drop
    functionality to an hbox.
    > You're probably thinking "just use a tilelist", and
    that's what i'm
    > currently
    > using, but the tilelist cannot align items to the
    center, which is crucial
    > in
    > my application (if you need me to explain further i
    will, but i don't
    > think
    > it's relevant here).
    Sure it can.
    > So i need drag and drop on an Hbox. The repeater is
    necessary because the
    > hbox
    > may need to be populated with items initially, which can
    later be dragged
    > and
    > dropped either in itself (to re-arrange items) or into
    another hbox of
    > this
    > kind. For the past few hours I've been trying to find
    anything that can
    > even
    > hint at this type of functionality (i've been searching
    and experimenting
    > for
    > hours). If anyone can point me in the right direction,
    i'd appreciate it.
    > Thank
    > you very much. -b
    http://www.quilix.com/node/3

  • Drag and Drop using Components[

    Hi,
    As anyone used Drag and Drop for components? I mean, allowing the user to drag and drop a component around a container? Just curious, so far from what I've seen, the only things that can be dragged/dropped are properties of a given object, such as 'text" from a JLabel.
    thanks

    IMHO, you don't need fancy drag and drop features to do that. Implementing MouseInputListener and listening for mouseDragged is a good start. Then setting the component's bounds depending on the location of the mouse at the mouseReleased event (wrt the starting offset) could be a good idea (if you're using absolute positioning, of course).
    From there, it all depends on what you want it to look like during the "transfer". You could, for instance paint the component in a BufferedImage at the start of the D&D and then paint the image with transparency as the mouse is moving.
    Camickr had an interesting post that might help you :
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=492100

  • Drag and Drop to the DeskTop

    Hi,
    I would like to be able to drag and drop a component from my Java application
    and for this component to be shown on the desk top. The idea is to have monitor
    components on the desktop which are always on top but small enough so that they
    do not take up as much space as when the window containing these components
    are open.
    I have seen an example program that does just this, it is the ICQ client. With this program
    you can create an ICQ user in the application. Dragging this user onto the desktop causes that
    componenr to remain on the desktop on top of all apps even twhen the program is restarted.
    Cool.
    Anyone know how this can be acheived in Java or via Windows API using JNI.
    Regards
    Steve
    .

    Look in the Applications folder to see if iPhoto is still there. If it is drag it back to the Finder Sidebar. If it is no longer in the Applications folder post back, you can also look in the Trash it might still be there.

  • Drag and drop a jcomponent

    I want to drag and drop a component like textbox in MS Word. I figured out that you can drag and drop image and text easily. However to drag and drop a component you may need JavaBeans Bridge for ActiveX.
    I did a little bit of research for this. I came across a tutorial from a website:
    http://www.javaworld.com/javaworld/jw-09-1998/jw-09-bridge.html
    I am novice to JavaBeans Bridge for ActiveX and I have no idea how to incorporate this in my application.
    Please help me.
    Thanks,
    Riddhi.

    It's not advanced it's ESSENTIAL and is not possible to write by hand because the NetBeans regenerate the code.....
    or "by hand" means to write
    setBounds(217,131,24,37)??????????
    I use this in DOS programms !!!!!! Pascal for DOS , FoxPro for DOS!!!!!

  • Custom Drag and Drop Component: When i add a skin, drag and drop no longer works?

    I have a skinnableContainer that acts as a container for other drag and droppable items. This container's drop functionality is added from it's parent at the same moment the container is added.
    This all works fine until i add a skin class to the skinnableContainer, now none of the draggable items can drop into the container as it did before.
    I assume that the Group component wrapping the content from within the skin is acting as a block somehow, but i'm not sure how to allow the drop functionality through it?
    Any ideas? Thanks in advance.

    Hello,
    Thanks for your replies... I tried modifying the if clause,
    but it did not work. I can use a trace statement to find out what
    the target is and what level it is at, but I cannot do this when it
    is in our presenter window.
    The code that is causing the problem can be accessed right in
    Flash. Just create a new quiz, then in the library, go to Quiz
    Files --> Learning Interactions --> Assets --> Controls
    --> Components, right click on drag and drop and select edit and
    then go to the actions frame. I am sure you already know this, but
    I just want to be clear I did not make this from scratch.
    This code works great when the quiz is the root movie. But if
    the quiz is encapsulated within another movie, it does not work. I
    can drag the objects, but they just snap back to where their
    starting points are. In the code I attached earlier...
    "this._parent.Target1" used to be "target".
    Just so you can see it all, I have attached the problematic
    function.
    What happens is that if "this._parent.Target1" is set to
    "target", the movie will function fine in Flash, but will not work
    in our presentation window. I can drag the draggable objects, but
    they always snap back to the location of where they came from.
    What this means is that the if clauses are not being run, and
    the function is always running the else clause, which puts all of
    the objects back at their starting point.
    In the code attached, I am using "this._parent.Target1".
    Again, works fine in Flash, but when I put it in the presentation
    window, this time, I can drag the objects anywhere on the screen,
    but when I drop them, they think that the dropZone is the question
    itself, and not the Target (Target1). So I need to figure out how
    to make Target1 be the dropZone in our presentation window.
    Any ideas?
    Thanks again for all your help!

  • Drag and Drop - detecting drop away from a component

    Flex 4, AIR 2.0 app
    I have a drag and drop detecting a Button drag away from a Group1 into Group2.
    When the user drops into a Group2, the Button is added to it, which obviously removes it from Group1.
    I would like it that if the user drags away from Group2 and drops it randomly on the screen, the Button will be added back into Group1.
    Does anyone have any ideas as to how I might go about detecting the end of a drag when not over a component, so I can add the button back into Group1 again?
    Hope that makes sense!!!

    Thanks Ronnie,
    I'll have a look at gthis as it looks a bit more efficient than the solution I have come up with.
    The only thing I'm not sure about is at what point my Button gets put back into Group1.  In my current movie, I have a function which handles the dragDrop event.  But if I drop outside a component, I don't have an event from which I call the handleDrop(dragEvent) function.
    I'll have a look.
    In the meantime, what I'm doing is Making my drag item a custom component, passing a reference to it's default container (Group1) and its Default X and Y co-ordinates.
    Then, I have a dragComplete handler which is called whenever the drag item is released - I then check the action property of the event and if it is "none" I know it has been dropped outside a recognised target and I can add it back into its default group and set its default x and y coordinates.  This seems to work quite nicely at the moment.
    so, my code in the Drag Button looks like this:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Button xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/mx"
        mouseDown="mouseDownHandler(event)"
        dragComplete="dragCompleteHandler(event)">
    <fx:Script>
      <![CDATA[  
       import mx.core.DragSource;
       import mx.core.IUIComponent;
       import mx.events.DragEvent;
       import mx.managers.DragManager;
       public var _defaultParent:Object;
       public var _defaultX:Number;
       public var _defaultY:Number;
       protected function mouseDownHandler(event:MouseEvent):void
        // the drag initiator is the object being dragged (target of the mouse event)
        var dragInitiator:IUIComponent = event.currentTarget as IUIComponent;
        // the drag source contains data about what's being dragged
        var dragSource:DragSource = new DragSource();
        // ask the DragManger to begin the drag
        DragManager.doDrag( dragInitiator, dragSource, event, null );
       protected function dragCompleteHandler(event:DragEvent):void
        // TODO Auto-generated method stub
        //trace("Drag complete!");
        //trace("target = " + event.target);
        //trace("action = " + event.action);
        if (event.action != "none"){
         trace("woo!");
        }else{
         trace("put the drag label back into its original position");
         if (event.target.parent != _defaultParent){
          trace("put it back, you monster!");
          _defaultParent.addElement(event.target);
          event.target.x = _defaultX;
          event.target.y = _defaultY;
         }else{
          trace("ah... it's already in the right place... actually!");
      ]]>
    </fx:Script>
    </s:Button>

  • Drag and Drop of Page from Content Finder into Page Component

    Hi,
    Does anybody has a sample code for Page component which accepts the page when dragging and dropping from the content finder? Basically I am trying to create a web page with page component on it and customized the content finder to display all the pages that I needed on a separate tab, I am trying to drag and drop the pages from the content finder to the page component of the web page that I created, but it is not working for me. If someone has any sample working code please share it.
    Thanks

    Hi,
    There's no direct support for this. But you could implement
    drag and drop the way you normally would in javascript. Except
    here, on mouseUp over a div encapsulating the object or embed tag
    (the flash object), you'll need to make a call into actionscript
    from javascript indicating that a drag and drop happened.
    For more info, see
    how
    to drag and drop using javascript and
    actionscript
    and javascript communication

  • Can you use a custom cursor with drag and drop?

    Hi there! I'm a newbie flash user and working on a simulation for a graduate course in instructional design. I'm using Flash Professional CC on Mac. Here's what I'm trying to do. I have several draggable sprites on the stage and three target sprites. I have specified the original x,y locations of the sprites and have set the end x,y locations as those of each of the three targets. Items must be dragged to one of the three targets.
    Some questions:
    1. Can I specify more than one End x,y location for a draggable sprite? I'm creating a lesson to teach kindergartners how to sort lunchroom waste. If they have a napkin, for example, it could either go into the compost OR into the recycling. In cases like this where an item could really be placed into more than one bin, I want them to get it right if they do either of those things, rather than forcing them to choose which one.
    2. To make my project more "fun" for kids, I wanted to customize the cursor with a graphic of  hand. When I tried this in the flash file it works perfectly until I add the drag and drop functionality for the wasted items. Then the cursor will more around  but not pick up any items. Once I revert back to the standard pointer, the correct drag and drop functionality is restored.
    3. I have it set to snap back to the original location if learner attempts to drop the item on the wrong target. I want to be able to play a sound file when that happens, as well as play a sound file when it lands on the correct target, as well as shrink the item and change its opacity so that it appears invisible. I want to give the illusion of it being placed into the bin. I have no idea as to the proper way to code these events so that they happen.
    4. I've watched dozens of hours of youtube tutorials before coming here. I'm a quick study, but am very new to action script. In one of the videos the developer showed referencing an external action script file which I don't think is an option in CC. The coding method he used seemed much more streamlined and "clean" than the chunks I'm working with now. Is there an easy way for me to code information about these objects  than the way I've got it here now? I hate starting new things with bad habits. The perils of self-teaching.
    Thanks!
    I'm pasting my code from the actions panel below so you can see what's going on:
    stop();
    /* Custom Mouse Cursor
    Replaces the default mouse cursor with the specified symbol instance.
    stage.addChild(customcursor);
    customcursor.mouseEnabled = false;
    customcursor.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor);
    function fl_CustomMouseCursor(event:Event)
      customcursor.x = stage.mouseX;
      customcursor.y = stage.mouseY;
    Mouse.hide();
    //To restore the default mouse pointer, uncomment the following lines:
    customcursor.removeEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor);
    stage.removeChild(customcursor);
    Mouse.show();
    //set up variables and objects for dragging
    var offset:int = 10;
    var appleStartX:int = 243;
    var appleStartY:int = 156;
    var appleEndX:int = 522;
    var appleEndY:int = 22;
    apple.buttonMode = true;
    apple.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    apple.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var cupStartX:int = 39;
    var cupStartY:int = 266;
    var cupEndX:int = 520;
    var cupEndY:int = 175;
    cup.buttonMode = true;
    cup.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    cup.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var barStartX:int = 178;
    var barStartY:int = 234;
    var barEndX:int = 522;
    var barEndY:int = 22;
    bar.buttonMode = true;
    bar.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    bar.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var orangeStartX:int = 284;
    var orangeStartY:int = 102;
    var orangeEndX:int = 522;
    var orangeEndY:int = 22;
    orange.buttonMode = true;
    orange.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    orange.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var bottleStartX:int = 172;
    var bottleStartY:int = 303;
    var bottleEndX:int = 520;
    var bottleEndY:int = 175;
    bottle.buttonMode = true;
    bottle.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    bottle.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var bananaStartX:int = 113;
    var bananaStartY:int = 123;
    var bananaEndX:int = 522;
    var bananaEndY:int = 22;
    banana.buttonMode = true;
    banana.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    banana.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var napkinStartX:int = 248;
    var napkinStartY:int = 271;
    var napkinEndX:int = 520;
    var napkinEndY:int = 175;
    napkin.buttonMode = true;
    napkin.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    napkin.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var yogurtStartX:int = 27;
    var yogurtStartY:int = 136;
    var yogurtEndX:int = 518;
    var yogurtEndY:int = 329;
    yogurt.buttonMode = true;
    yogurt.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    yogurt.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var strawberryStartX:int = 120;
    var strawberryStartY:int = 285;
    var strawberryEndX:int = 522;
    var strawberryEndY:int = 22;
    strawberry.buttonMode = true;
    strawberry.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    strawberry.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var sandwichStartX:int = 7;
    var sandwichStartY:int = 364;
    var sandwichEndX:int = 522;
    var sandwichEndY:int = 22;
    sandwich.buttonMode = true;
    sandwich.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    sandwich.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var juiceStartX:int = 88;
    var juiceStartY:int = 347;
    var juiceEndX:int = 518;
    var juiceEndY:int = 329;
    juice.buttonMode = true;
    juice.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    juice.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var foilStartX:int = 39;
    var foilStartY:int = 416;
    var foilEndX:int = 520;
    var foilEndY:int = 175;
    foil.buttonMode = true;
    foil.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    foil.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    var waxbagStartX:int = 235;
    var waxbagStartY:int = 342;
    var waxbagEndX:int = 522;
    var waxbagEndY:int = 22;
    waxbag.buttonMode = true;
    waxbag.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
    waxbag.addEventListener(MouseEvent.MOUSE_UP, stopDragging);
    function startDragging (e:MouseEvent) {
      e.currentTarget.startDrag();
    function stopDragging (e:MouseEvent) {
      e.currentTarget.stopDrag();
      switch (e.currentTarget) {
      case apple:
      if (apple.x < appleEndX - offset || apple.x > appleEndX + offset || apple.y < appleEndY - offset || apple.y > appleEndY + offset) {
      apple.x = appleStartX;
      apple.y = appleStartY;
      else {
      apple.x = appleEndX;
      apple.y = appleEndY;
      //checkGame();
      break;
      case sandwich:
    if (sandwich.x < sandwichEndX - offset || sandwich.x > sandwichEndX + offset || sandwich.y < sandwichEndY - offset || sandwich.y > sandwichEndY + offset) {
      sandwich.x = sandwichStartX;
      sandwich.y = sandwichStartY;
      else {
      sandwich.x = sandwichEndX;
      sandwich.y = sandwichEndY;
      //checkGame();
      break;
      case orange:
    if (orange.x < orangeEndX - offset || orange.x > orangeEndX + offset || orange.y < orangeEndY - offset || orange.y > orangeEndY + offset) {
      orange.x = orangeStartX;
      orange.y = orangeStartY;
      else {
      orange.x = orangeEndX;
      orange.y = orangeEndY;
      //checkGame();
      break;
      case strawberry:
    if (strawberry.x < strawberryEndX - offset || strawberry.x > strawberryEndX + offset || strawberry.y < strawberryEndY - offset || strawberry.y > strawberryEndY + offset) {
      strawberry.x = strawberryStartX;
      strawberry.y = strawberryStartY;
      else {
      strawberry.x = strawberryEndX;
      strawberry.y = strawberryEndY;
      //checkGame();
      break;
      case napkin:
    if (napkin.x < napkinEndX - offset || napkin.x > napkinEndX + offset || napkin.y < napkinEndY - offset || napkin.y > napkinEndY + offset) {
      napkin.x = napkinStartX;
      napkin.y = napkinStartY;
      else {
      napkin.x = napkinEndX;
      napkin.y = napkinEndY;
      //checkGame();
      break;
      case bar:
    if (bar.x < barEndX - offset || bar.x > barEndX + offset || bar.y < barEndY - offset || bar.y > barEndY + offset) {
      bar.x = barStartX;
      bar.y = barStartY;
      else {
      bar.x = barEndX;
      bar.y = barEndY;
      //checkGame();
      break;
      case juice:
    if (juice.x < juiceEndX - offset || juice.x > juiceEndX + offset || juice.y < juiceEndY - offset || juice.y > juiceEndY + offset) {
      juice.x = juiceStartX;
      juice.y = juiceStartY;
      else {
      juice.x = juiceEndX;
      juice.y = juiceEndY;
      //checkGame();
      break;
      case foil:
    if (foil.x < foilEndX - offset || foil.x > foilEndX + offset || foil.y < foilEndY - offset || foil.y > foilEndY + offset) {
      foil.x = foilStartX;
      foil.y = foilStartY;
      else {
      foil.x = foilEndX;
      foil.y = foilEndY;
      //checkGame();
      break;
      case banana:
    if (banana.x < bananaEndX - offset || banana.x > bananaEndX + offset || banana.y < bananaEndY - offset || banana.y > bananaEndY + offset) {
      banana.x = bananaStartX;
      banana.y = bananaStartY;
      else {
      banana.x = bananaEndX;
      banana.y = bananaEndY;
      //checkGame();
      break;
      case bottle:
    if (bottle.x < bottleEndX - offset || bottle.x > bottleEndX + offset || bottle.y < bottleEndY - offset || bottle.y > bottleEndY + offset) {
      bottle.x = bottleStartX;
      bottle.y = bottleStartY;
      else {
      bottle.x = bottleEndX;
      bottle.y = bottleEndY;
      //checkGame();
      break;
      case waxbag:
    if (waxbag.x < waxbagEndX - offset || waxbag.x > waxbagEndX + offset || waxbag.y < waxbagEndY - offset || waxbag.y > waxbagEndY + offset) {
      waxbag.x = waxbagStartX;
      waxbag.y = waxbagStartY;
      else {
      waxbag.x = waxbagEndX;
      waxbag.y = waxbagEndY;
      //checkGame();
      break;
      case cup:
    if (cup.x < cupEndX - offset || cup.x > cupEndX + offset || cup.y < cupEndY - offset || cup.y > cupEndY + offset) {
      cup.x = cupStartX;
      cup.y = cupStartY;
      else {
      cup.x = cupEndX;
      cup.y = cupEndY;
      //checkGame();
      break;
      case yogurt:
    if (yogurt.x < yogurtEndX - offset || yogurt.x > yogurtEndX + offset || yogurt.y < yogurtEndY - offset || yogurt.y > yogurtEndY + offset) {
      yogurt.x = yogurtStartX;
      yogurt.y = yogurtStartY;
      else {
      waxbag.x = waxbagEndX;
      waxbag.y = waxbagEndY;
      //checkGame();

    Some questions:
    1. Can I specify more than one End x,y location for a draggable sprite?
    yes, use an if-else statement
    I'm creating a lesson to teach kindergartners how to sort lunchroom waste. If they have a napkin, for example, it could either go into the compost OR into the recycling. In cases like this where an item could really be placed into more than one bin, I want them to get it right if they do either of those things, rather than forcing them to choose which one.
    2. To make my project more "fun" for kids, I wanted to customize the cursor with a graphic of  hand. When I tried this in the flash file it works perfectly until I add the drag and drop functionality for the wasted items. Then the cursor will more around  but not pick up any items. Once I revert back to the standard pointer, the correct drag and drop functionality is restored.
    assign your cursor's mouseEnabled property to false:
    yourcursor.mouseEnabled=false;
    3. I have it set to snap back to the original location if learner attempts to drop the item on the wrong target. I want to be able to play a sound file when that happens, as well as play a sound file when it lands on the correct target, as well as shrink the item and change its opacity so that it appears invisible. I want to give the illusion of it being placed into the bin. I have no idea as to the proper way to code these events so that they happen.
    use the sound class to create a sound:
    // initialize your correct sound once with
    var correctSound:Sound=new CorrectSound();  // add an mp3 sound to your library and assign it class = CorrectSound
    // apply the play() method everytime you want your sound to play:
    correctSound.play();
    // change an object's opacity:
    someobject.alpha = .3;  // partially visible
    someobject.alpha = 1;  // fully visible
    someobject.visible=false;  // not visible, at all.
    // change an object's scale
    someobject.scaleX=someobject.scaleY=.5;  // shink width and height by 2
    someobject.scaleX=someobject.scaleY=1;  // resize to original
    4. I've watched dozens of hours of youtube tutorials before coming here. I'm a quick study, but am very new to action script. In one of the videos the developer showed referencing an external action script file which I don't think is an option in CC. The coding method he used seemed much more streamlined and "clean" than the chunks I'm working with now. Is there an easy way for me to code information about these objects  than the way I've got it here now? I hate starting new things with bad habits. The perils of self-teaching.
    you could google: 
    actionscript 3 class coding
    actionscript 3 object oriented programming
    p.s.  you can simplify and streamline your coding by learning about arrays and using hitTestObject.

  • Drag and Drop inside a component

    I am using the Project Gantt component and want to drag and drop inside the component. I want to drag a timeline from one row and drop it to another row. And also drag a timeline from a row and drop it another place in the same row. Can I make the component a dragsource and droptarget?

    Hi,
    should be posted at JDeveloper and OC4J 11g Technology Preview
    Frank

  • Drag and Drop in custom components..

    hello friends,
    I am trying to devlop a schedule component. on part of this i trying to develop a functionality where the user can reschedure the appointment by drag and drop.  the dragdrop event in the container component is not triggered when ther user drag the appointment and drop it in the another container. can any one help me on this please. i have given below my source codes.
    Testbox.as
    package layouts.DayViewControl.containers
        import mx.core.Container;
        public class TestBox extends Container
            private var __timeAndXYCoOrdArray:Array;
            private var __xyDiff:int=0;
            public function TestBox()
                super();
                __timeAndXYCoOrdArray=new Array();
            protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
                super.updateDisplayList(unscaledWidth,unscaledHeight);
                var totalSlots:int=24*2;
                var __lineThickness:int=1;
                var __lineAlpha:int=0.2;
                var boxHeight:uint=unscaledHeight/totalSlots;
                graphics.clear();
                var xPos:int=0;
                var ypos:int=0;
                graphics.lineStyle(2,0x000000,0.5);
                graphics.drawRect(0,0,unscaledWidth,unscaledHeight);
                var __boxHeight:int=unscaledHeight/totalSlots;
                var __minusCount:int=1;
                for(var i:int=0;i<totalSlots;i++){
                    var timeStr:String="";
                    if(i%2 == 0){
                        __lineThickness=2;
                        graphics.lineStyle(__lineThickness,0x000000,0.4);               
                    }else{
                        __lineThickness=1;
                        graphics.lineStyle(__lineThickness,0x000000,0.2);   
                    graphics.moveTo(xPos,ypos);
                    var tempYpos:int=ypos;
                    if(__xyDiff == 0){
                        __xyDiff=ypos-xPos;
                    graphics.lineTo(xPos+unscaledWidth,tempYpos);
                    ypos+=boxHeight;
                    var newYPos:int=0;
                    if(i == 0){
                        timeStr="00:00";
                    }else if(i%2 != 0){
                        if(i<=9){
                            timeStr="0"+(i-__minusCount).toString()+":30";
                        }else{
                            timeStr=(i-__minusCount).toString()+":30";                       
                        newYPos=ypos-__xyDiff;
                    }else if(i%2 == 0){
                        if(i<=9){
                            timeStr="0"+(i-__minusCount).toString()+":00";
                        }else{
                            timeStr=(i-__minusCount).toString()+":00";                       
                        __minusCount+=1;
                        newYPos=ypos-__xyDiff;
                    __timeAndXYCoOrdArray.push({XPos:xPos,YPos:newYPos,Time:timeStr});
            public function getXFromtime(inputTime:String):int{
                var returnVal:int=0;
                if(inputTime && inputTime != ""){
                    for (var j:int=0;j<__timeAndXYCoOrdArray.length;j++){
                        if(__timeAndXYCoOrdArray[j].Time.toString() == inputTime){
                            returnVal=parseInt(__timeAndXYCoOrdArray[j].XPos)
                            break;
                return returnVal;
            public function getYFromtime(inputTime:String):int{
                var returnVal:int=0;
                if(inputTime && inputTime != ""){
                    for (var j:int=0;j<__timeAndXYCoOrdArray.length;j++){
                        if(__timeAndXYCoOrdArray[j].Time.toString() == inputTime){
                            returnVal=parseInt(__timeAndXYCoOrdArray[j].YPos)
                            break;
                return returnVal;
            public function getTimeDifference():int{
                return __xyDiff;
    TimeDividerLines.as
    package layouts.DayViewControl
        import flash.events.MouseEvent;
        import flash.utils.Dictionary;
        import layouts.DayViewControl.containers.TestBox;
        import mx.collections.ArrayCollection;
        import mx.core.DragSource;
        import mx.core.EventPriority;
        import mx.core.UIComponent;
        import mx.events.DragEvent;
        import mx.managers.DragManager;
        public class TimeDividerLines extends TestBox
            private var __linesPerHour:int=4;
            private var __currentDate:Date;
            private var __timeAndXYCoOrdArray:Array;
            private var __dataComponentArry:Array;
            private var __totalAppointment:int=5;
            private var __xyDiff:int=0;
            private var __apptDataInfoArry:Array;
            private var __dataProviderChanged:Boolean=false;
            private var __reArrangeDataArrayCol:ArrayCollection;
            private var __sortedArrayCollection:ArrayCollection;
            private var __dragDropEnabled:Boolean=false;
            public function TimeDividerLines()
                super();
                //__timeAndXYCoOrdArray=new Array();
                __dataComponentArry=new Array();
                __apptDataInfoArry=new Array();
                __sortedArrayCollection=new ArrayCollection();   
            public function set dragDropEnabled(inputVal:Boolean):void{
                if(inputVal){
                    //set youself for drag and drop event
                    this.addEventListener(DragEvent.DRAG_ENTER,dragEnterEventHandler,false,EventPriority.DEFA ULT_HANDLER);
                    this.addEventListener(DragEvent.DRAG_OVER,dragOverEventHandler,false,EventPriority.DEFAUL T_HANDLER);
                    this.addEventListener(DragEvent.DRAG_DROP,dragDropEventHandler,false,EventPriority.DEFAUL T_HANDLER);
                    this.addEventListener(DragEvent.DRAG_COMPLETE,dropCompleteHandler);               
                }else{
                    this.removeEventListener(DragEvent.DRAG_ENTER,dragEnterEventHandler,false);
                    this.removeEventListener(DragEvent.DRAG_OVER,dragOverEventHandler,false);
                    this.removeEventListener(DragEvent.DRAG_DROP,dragDropEventHandler,false);               
                __dragDropEnabled=inputVal;
            private function dropCompleteHandler(event:DragEvent):void{
                trace("inside drop complete handler");
            private function dragEnterEventHandler(event:DragEvent):void{
                if(event.dragSource.hasFormat("Appointment")){
                    var dropTarget:UIComponent=UIComponent(event.currentTarget);
                    DragManager.acceptDragDrop(dropTarget);           
                    DragManager.showFeedback(event.ctrlKey ? DragManager.COPY : DragManager.MOVE);   
                    return;
                DragManager.showFeedback(DragManager.NONE);
            private function dragOverEventHandler(event:DragEvent):void{
                /* if(event.dragSource.hasFormat("Appointment")){
                    if(event.ctrlKey){
                        DragManager.showFeedback(DragManager.COPY);
                        return
                    }else{
                        DragManager.showFeedback(DragManager.MOVE);
                        return
                DragManager.showFeedback(DragManager.NONE); */
            private function dragDropEventHandler(event:DragEvent):void{
                //We need to do two things here. you need to add the dropped data to the data provider list.
                //and need need to update this entry to DB
                 /* if(event.dragSource.hasFormat("Appointment")){
                     var draggedbox:AppointmentDisplayBox=event.dragSource.dataForFormat("Appointment") as AppointmentDisplayBox;
                     var dropBox:TimeDividerLines=event.currentTarget as TimeDividerLines;
                     //create a new copy
                     var newBox:AppointmentDisplayBox=new AppointmentDisplayBox();
                     newBox=draggedbox;
                     newBox.x=dropBox.mouseX;
                     newBox.y=dropBox.mouseY;
                     this.addChild(newBox);
                 trace("11111111111111111111111111111111111111111")
            private function mouseDownHandler(event:MouseEvent):void{
                var draginit:AppointmentDisplayBox=AppointmentDisplayBox(event.currentTarget);
                var ds:DragSource=new DragSource();
                ds.addData(draginit,"Appointment");
                DragManager.doDrag(draginit,ds,event);
            override protected function createChildren():void{
                super.createChildren();
            override protected function commitProperties():void{
                 if(__dataProviderChanged){
                     __dataComponentArry=new Array();
                    for (var k:int=0;k<__apptDataInfoArry.length;k++){
                        var tempDispBox:AppointmentDisplayBox=new AppointmentDisplayBox();
                        tempDispBox.currentDate=this.currentDate;
                        tempDispBox.startTime=__apptDataInfoArry[k].StartTime.toString();
                        tempDispBox.endTime=__apptDataInfoArry[k].EndTime.toString();
                        tempDispBox.apptDataXml=__apptDataInfoArry[k].Data as XML;       
                        tempDispBox.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);           
                        this.addChild(tempDispBox);
                        __dataComponentArry.push(tempDispBox);
                    __dataProviderChanged=false;
            private function sortTheCollectionValues(__inputArrayCol:ArrayCollection):ArrayCollection{
                var returnArrayCollection:ArrayCollection=new ArrayCollection();
                var tempArray:Array=new Array();
                for(var i:int=0;i<__inputArrayCol.length;i++){
                    tempArray.push({Length:(__inputArrayCol[i] as Array).length,Index:i});
                tempArray.sortOn("Length",Array.DESCENDING|Array.NUMERIC);
                for(var j:int=0;j<tempArray.length;j++){
                    returnArrayCollection.addItem(__inputArrayCol[tempArray[j].Index]);
                return returnArrayCollection;
            override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
                super.updateDisplayList(unscaledWidth,unscaledHeight);
                if(__dataComponentArry.length > 0){
                    __sortedArrayCollection=new ArrayCollection();
                    sortArray(__dataComponentArry);
                if(__sortedArrayCollection.length > 0 ){
                    //you need to sort the arraycollection based on the length first to draw the highest no. child array first
                    __sortedArrayCollection=sortTheCollectionValues(__sortedArrayCollection);
                    var appGap:int=2;
                    var endGap:int=10;
                    //var drawnApptObj:Array=new Array();
                    var existingChildArray:Array=new Array();   
                    var drawnApptObj:Dictionary=new Dictionary();
                    for(var l:int=0;l<__sortedArrayCollection.length;l++){
                        var apptWidth:int=0;
                        var innerArry:Array=__sortedArrayCollection[l] as Array;
                        existingChildArray=new Array();
                        //you need to recalculate the width
                        //for the first iteration you need to sort by height
                        //if(l == 0){
                        //    innerArry.sortOn("apptHeight",Array.NUMERIC|Array.DESCENDING);
                        //}else{
                            innerArry.sortOn(["isChild","apptHeight"],Array.NUMERIC|Array.DESCENDING);   
                        //innerArry.sortOn("apptHeight",Array.NUMERIC|Array.DESCENDING);
                        //first we need to find out any intersection appointment is there
                        var count:int=0;
                         for each(var tempApptDispBox:AppointmentDisplayBox in innerArry){
                            if(drawnApptObj[tempApptDispBox] == tempApptDispBox){
                                if(apptWidth < tempApptDispBox.width){
                                    apptWidth=tempApptDispBox.width;
                                    existingChildArray.push({index:count,object:tempApptDispBox});
                            count++;
                        if(apptWidth == 0){
                            apptWidth=(unscaledWidth - (endGap + (appGap*innerArry.length)))/innerArry.length;
                        //now you need to layout the childrens
                        var canDraw:Boolean=false;
                        var ismatch:Boolean=false;
                        for (var childCnt:int=0;childCnt < innerArry.length;childCnt++){
                             var tempDispBox:AppointmentDisplayBox=innerArry[childCnt] as AppointmentDisplayBox;
                             for (var i:int=0;i<existingChildArray.length;i++){
                                 if(existingChildArray[i].index == childCnt){
                                     ismatch=true;
                                     break;
                            if(childCnt == 0 && !ismatch){
                                tempDispBox.x=this.getXFromtime(tempDispBox.startTime.toString())+2;
                                canDraw=true;
                            }else if(existingChildArray.indexOf(childCnt) > -1 && childCnt != 0){
                                //tempDispBox.x=(existingChildArray[childCnt] as AppointmentDisplayBox).x+apptWidth+appGap;
                                canDraw=false;
                            }else if(childCnt != 0 && !ismatch){
                                tempDispBox.x=((existingChildArray[childCnt-1].object) as AppointmentDisplayBox).x+apptWidth+appGap;
                                canDraw=true;
                            if(canDraw){
                                tempDispBox.y=this.getYFromtime(tempDispBox.startTime.toString());   
                                tempDispBox.width=apptWidth;
                                tempDispBox.height=tempDispBox.apptHeight-2;
                                if(tempDispBox.isChild){
                                    drawnApptObj[tempDispBox]=tempDispBox;
                                existingChildArray.push({index:childCnt,object:tempDispBox});
                            canDraw=false;
                            ismatch=false;
                //first we need to sort the component array based on the height property to position the biggest appointment first
            private function sortArray(tempArry:Array):void{
                //var tempArry:Array=arrayClone(__datacompArray);
                 for(var i:int=0;i<tempArry.length;i++){
                     var tempDispBox:AppointmentDisplayBox=tempArry[i] as AppointmentDisplayBox;
                    var start:int=this.getYFromtime(tempDispBox.startTime.toString());
                    var end:int=this.getYFromtime(tempDispBox.endTime.toString());
                    tempDispBox.apptHeight=end-start;
                var indexArray:Array=new Array();
                var canContinue:Boolean=false;
                var loopArray:Array=new Array();
                loopArray=tempArry.concat(); // this will copy the array to loopArray
                var copyArry:Array=new Array();
                var k:int=0;
                while(k<loopArray.length){
                    loopArray.sortOn("apptHeight",Array.NUMERIC|Array.DESCENDING);
                    if(indexArray.length > 0){
                        if(indexArray.indexOf(k) >= 0){
                            canContinue=false;
                        }else{
                            canContinue=true;
                    }else{
                        canContinue=true;
                    if(canContinue){
                        var newArry:Array=new Array();
                        //newArry.push(tempArry[k]);                   
                        for (var innerCnt:int=0;innerCnt<loopArray.length;innerCnt++){
                            var locCanContinue:Boolean=false;
                            if(indexArray.length > 0){
                                if(indexArray.indexOf(innerCnt) >= 0){
                                    locCanContinue=false;
                                }else{
                                    locCanContinue=true;
                            }else{
                                locCanContinue=true;
                            if(locCanContinue && k != innerCnt){
                                var outerstartTime:Number=parseFloat(loopArray[k].startTime.toString().replace(":","."));
                                var outerendtime:Number=parseFloat(loopArray[k].endTime.toString().replace(":","."));
                                var innerStartTime:Number=parseFloat(loopArray[innerCnt].startTime.toString().replace(":","." ));
                                var innerEndtime:Number=parseFloat(loopArray[innerCnt].endTime.toString().replace(":","."));
                                if(outerstartTime == innerStartTime && outerendtime == innerEndtime){
                                    //newArry.push(tempArry.splice(innerCnt,1));
                                    newArry.push(loopArray[innerCnt]);
                                    indexArray.push(innerCnt);
                                }else if(outerstartTime == innerStartTime && outerendtime > innerEndtime){
                                    //newArry.push(tempArry.splice(innerCnt,1));
                                    newArry.push(loopArray[innerCnt]);
                                    indexArray.push(innerCnt);
                                }else if(outerstartTime  < innerStartTime && outerendtime == innerEndtime){
                                    //newArry.push(tempArry.splice(innerCnt,1));
                                    newArry.push(loopArray[innerCnt]);
                                    indexArray.push(innerCnt);
                                }else if(outerstartTime  < innerStartTime && outerendtime > innerEndtime){
                                    //newArry.push(tempArry.splice(innerCnt,1));
                                    newArry.push(loopArray[innerCnt]);
                                    indexArray.push(innerCnt);
                                }else if(outerstartTime > innerStartTime && outerendtime > innerEndtime && innerEndtime > outerstartTime){
                                    //newArry.push(tempArry.splice(innerCnt,1));
                                    newArry.push(loopArray[innerCnt]);
                                    loopArray[innerCnt].isChild=true;
                                    //indexArray.push(innerCnt);
                                }else if(outerstartTime < innerStartTime && outerendtime < innerEndtime && innerStartTime < outerendtime){
                                    //newArry.push(tempArry.splice(innerCnt,1));
                                    newArry.push(loopArray[innerCnt]);
                                    loopArray[innerCnt].isChild=true;
                                    //indexArray.push(innerCnt);
                                }else if(outerstartTime == innerStartTime && outerendtime < innerEndtime){
                                    newArry.push(loopArray[innerCnt]);
                                    loopArray[innerCnt].isChild=true;
                                }else if(outerstartTime > innerStartTime && outerendtime == innerEndtime){
                                    newArry.push(loopArray[innerCnt]);
                                    loopArray[innerCnt].isChild=true;
                        //newArry.push(tempArry.splice(k,1));
                        indexArray.push(k);
                        newArry.push(loopArray[k]);
                        __sortedArrayCollection.addItem(newArry);                   
                    copyArry=loopArray.concat();
                    loopArray=new Array();
                    for (var j:int=0;j<copyArry.length;j++){
                        if(indexArray.indexOf(j) < 0){
                            loopArray.push(copyArry[j]);
                    indexArray=new Array();               
            private function arrayClone(source:Array):Array{
                var returnArray:Array=new Array();
                for(var j:int=0;j<source.length;j++){
                    returnArray.push(source[j]);
                return returnArray;
            public function set currentDate(inputVal:Date):void{
                if(__currentDate != inputVal){
                    __currentDate=inputVal;
            public function get currentDate():Date{
                return __currentDate;
            public function set apptDataArray(inputVal:Array):void{
                if(!__dataProviderChanged && inputVal.length > 0){
                    __apptDataInfoArry=inputVal;
                    __dataProviderChanged=true;
                    invalidateProperties();
                    invalidateDisplayList();
    AppointmentDisplayBox.as
    package layouts.DayViewControl
        import mx.controls.TextInput;
        import mx.core.UIComponent;
        public class AppointmentDisplayBox extends UIComponent
            private var __startTime:String;
            private var __EndTime:String;
            private var __currentDate:Date;
            private var __apptData:XML;
            private var __height:Number;
            private var __isChild:Boolean=false;
            private var __modifiedWidth:Boolean=false;
            private var __docNameLable:TextInput;
            private var __appDetails:TextInput;
            public function AppointmentDisplayBox()
                super();
                this.setStyle("horizontalScrollPolicy","off");
                this.setStyle("verticalScrollPolicy","off");
                this.setStyle("borderStyle","solid");
                this.setStyle("verticalGap","0");
                this.setStyle("borderStyle","outset");       
                this.buttonMode=true;           
            protected override function createChildren():void{
                super.createChildren();
                if(!__docNameLable){
                    __docNameLable=new TextInput();
                    __docNameLable.editable=false;
                    __docNameLable.setStyle("horizontalScrollPolicy","off");
                    __docNameLable.setStyle("verticalScrollPolicy","off");
                    __docNameLable.setStyle("borderStyle","none");
                    //__docNameLable.setStyle("borderThickness","0");
                    __docNameLable.buttonMode=true;
                    addChild(__docNameLable);
                if(!__appDetails){
                    __appDetails=new TextInput();
                    __appDetails.editable=false;   
                    __appDetails.setStyle("horizontalScrollPolicy","off");
                    __appDetails.setStyle("verticalScrollPolicy","off");
                    __appDetails.setStyle("borderStyle","none");
                     __appDetails.setStyle("backgroundColor","0xB1FB17");
                     __appDetails.buttonMode=true;
                //    __appDetails.setStyle("borderThickness","0");
                    addChild(__appDetails);
            protected override function commitProperties():void{
                super.commitProperties();
                 if(__apptData != null){
                    __docNameLable.text=__apptData.DocName.toString();
                    __appDetails.text=__apptData.PatientID.toString()+"\n"+__apptData.Description.toString();                
                    invalidateDisplayList();
            protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
                super.updateDisplayList(unscaledWidth,unscaledHeight);
                __docNameLable.setActualSize(unscaledWidth-1,20);
                __docNameLable.move(1,1);
                graphics.clear();
                var lineColor:uint=0x000000;
                graphics.lineStyle(1,lineColor,1);
                graphics.beginFill(0xFEFDFD,1)
                graphics.drawRect(0,0,unscaledWidth,22);
                graphics.endFill();
                __appDetails.setActualSize(unscaledWidth-1,unscaledHeight-22);
                __appDetails.move(1,23);
                graphics.drawRect(0,22,unscaledWidth,unscaledHeight-20);
            public function set startTime(inputVal:String):void{
                __startTime=inputVal;
            public function get startTime():String{
                return __startTime;
            public function set endTime(inputVal:String):void{
                __EndTime=inputVal;
            public function get endTime():String{
                return __EndTime;
            public function set currentDate(inputVal:Date):void{
                __currentDate=inputVal;
            public function get currentDate():Date{
                return __currentDate;
            public function set apptHeight(inputVal:Number):void{
                __height=inputVal;
            public function get apptHeight():Number{
                return __height;
            public function set isChild(inputVal:Boolean):void{
                __isChild=inputVal;
            public function get isChild():Boolean{
                return __isChild;
            public function set isModifiedWidth(inputVal:Boolean):void{
                __modifiedWidth=inputVal;
            public function get isModifiedWidth():Boolean{
                return __modifiedWidth;
            public function set apptDataXml(inputVal:XML):void{
                if(__apptData != inputVal){
                    __apptData=inputVal;
                    invalidateProperties();
                    invalidateDisplayList();
            public function get apptDataXml():XML{
                return __apptData;
    Test.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:layouts="layouts.*"
        xmlns:DayViewControl="layouts.DayViewControl.*" xmlns:test="layouts.DayViewControl.containers.*">
        <mx:Script>
            <![CDATA[
                import mx.controls.TextInput;
                import layouts.DayViewControl.TimeDividerLines;
                import mx.events.DragEvent;
                import mx.managers.DragManager;
                import mx.core.DragSource;
                import layouts.DayViewControl.AppointmentDisplayBox;
                private function mouseDownHandler(event:MouseEvent):void{
                    var dragint:AppointmentDisplayBox=AppointmentDisplayBox(event.currentTarget);
                    //var dragint:TextInput=TextInput(event.currentTarget);
                    var ds:DragSource=new DragSource();
                    ds.addData(dragint,"Appoitment");
                    DragManager.doDrag(dragint,ds,event);               
                private function dragEnterHandler(event:DragEvent):void{
                    if(event.dragSource.hasFormat("Appoitment")){
                        var droptarget:TimeDividerLines=TimeDividerLines(event.currentTarget);
                        DragManager.acceptDragDrop(droptarget);
                        DragManager.showFeedback(event.ctrlKey?DragManager.COPY:DragManager.MOVE);
                        return;
                    DragManager.showFeedback(DragManager.NONE);
                private function dragDropHandler(event:DragEvent):void{
                    if(event.dragSource.hasFormat("Appoitment")){
                        var droppedObj:AppointmentDisplayBox=AppointmentDisplayBox(event.dragSource.dataForFormat("Ap poitment"));
                        //var droppedObj:TextInput=TextInput(event.dragSource.dataForFormat("Appoitment"));
                        var dropTarget:TimeDividerLines=TimeDividerLines(event.currentTarget);
                        droppedObj.x=dropTarget.mouseX;
                        droppedObj.y=dropTarget.mouseY;
                        dropTarget.addChild(droppedObj);
            ]]>
        </mx:Script>
        <mx:HBox width="100%" height="100%">
            <DayViewControl:TimeDividerLines width="50%" height="100%">
                <DayViewControl:AppointmentDisplayBox width="50" height="100" mouseDown="mouseDownHandler(event)"/>
            </DayViewControl:TimeDividerLines>
            <DayViewControl:TimeDividerLines width="50%" height="100%" dragEnter="dragEnterHandler(event)" dragDrop="dragDropHandler(event)"/>
        </mx:HBox>
    </mx:Application>

    First 3 .as are the component
    source. in the last test.mxml file i have written the drag and drop functionality.
    can any help me?? please

Maybe you are looking for