0 Replies Latest reply on Apr 9, 2008 10:03 AM by globerover

    Drag and Drop Issue

    globerover
      I have a drag and drop issue.

      Source is

      <mx:Panel x="48" y="125" width="800" height="600" layout="absolute" title="Drag onto Tree">

      <mx:Accordion id="accordion" width="200" height="450" left="10" top="10" bottom="10">
      <!-- Define each panel using a VBox container. -->
      <mx:VBox label="Events" >
      <mx:List width="200" height="450" right="10" bottom="10" id="eventlist"
      allowMultipleSelection="true"
      dataProvider="{events}"
      dragEnabled="true"
      dragMoveEnabled="true"
      >
      </mx:List>
      </mx:VBox> .......

      The Provider {event} is an array of Objects

      <mx:Array id="events">
      <mx:Object icon="startIcon" width="20" height="20" label="Start" />
      <mx:Object icon="endIcon" width="30%" height="30%" label="End"/>
      <mx:Object icon="intermediateIcon" width="30%" height="30%" label="Intermediate"/>
      <mx:Object icon="msgStartIcon" width="30%" height="30%" label="Message"/>
      <mx:Object icon="timerStartIcon" width="30%" height="30%" label="Timer"/>
      </mx:Array>


      Now the Target is a Canvas

      <mx:Canvas borderStyle="inset" height="420" width="520" left="250" top="10" bottom="10"
      dragEnter="onDragEnter(event)"
      dragDrop="onDragDrop(event)"
      dragOver="onDragOver(event)" >
      <mx:Panel id="lanes" width="100%" height="100%"/>
      </mx:Canvas>


      Now the dragDrop handler is as follows :

      private function onDragDrop( event:DragEvent ) : void

      {
      var ds:DragSource = event.dragSource;
      trace(ds);

      Alert.show("onDragDrop Clicked!");
      var formatArray:Array = ds.formats;
      for (var i:String in formatArray)
      {
      Alert.show(formatArray );
      }
      var draggedImage:Image = event.dragInitiator as Image;
      var dropCanvas:Canvas = event.currentTarget as Canvas;
      var newImage:Image=new Image();

      newImage.source = ds;
      newImage.x = dropCanvas.mouseX;
      newImage.y = dropCanvas.mouseY;
      dropCanvas.addChild(newImage);

      }

      Problem is Image does not get displayed. It shows a missing image icon on the target Canvas.