3 Replies Latest reply on Dec 28, 2007 9:19 PM by atta707

    Converting dropped component to a differnt type component

    Tikis_Mikis Level 1
      Hello Ok if you have been paying attention to my posts (as of last week no one has :-( ) I'm developing a drag and drop application.

      I have a List component in which I have dragEnabled="true". What I would like to do is drag an item in the list and "drop " it into a Canvas component where I want to take the object's data and create a Button component in the Canvas for it and the simplest way I can think of describing this process is to covert the item in the list after it has been dragged, then dropped into the target Canvas component. Is this at all possible? I have been trying different ways to retrieve the items information but have failed.

      In my Canvas component I call dragDrop="doDragDropMemberCanvas(event);"

      so how do I convert my "event" to a button?

      Here's my function (memberFilters is my Canvas):

      private function doDragDropMemberCanvas(event:DragEvent):void
      // Compensate for the mouse pointer's location in the title bar.
      var tempX:int = event.currentTarget.mouseX - xOff;
      event.dragInitiator.x = tempX;

      var tempY:int = event.currentTarget.mouseY - yOff;
      event.dragInitiator.y = tempY;

      // drop a child if it is dragged into the canvas
      // == memberFilters.addChild(Panel(event.dragInitiator));

      // Put the dragged panel on top of all other components.
      // == memberFilters.setChildIndex(Panel(event.dragInitiator), memberFilters.numChildren-1);
      memberFilters.setChildIndex(Button(event.dragInitiator), memberFilters.numChildren-1);