0 Replies Latest reply on Apr 21, 2007 3:46 AM by TigerArt

    Drag and drop problem

    TigerArt
      I'm trying to drag and drop pannels into VBoxes but the code i've written don't work !!!!
      VBoxes don't finf the source type .
      There is the code i've done the dragIt only for ine panel, just to ty


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="horizontal" backgroundGradientColors="[#e6dcc5, #dcccb4]">
      <mx:Script>
      <![CDATA[
      import mx.events.DragEvent;
      import mx.core.DragSource;
      import mx.managers.DragManager;

      private function dragIt(e:MouseEvent, text:String, format:String):void
      {
      var initiateur:Panel = Panel(e.currentTarget);
      var source:DragSource = new DragSource();
      source.addData(text, 'panneau');
      var panelproxy:Panel = new Panel();
      panelproxy.width = initiateur.width;
      panelproxy.height = initiateur.height;
      //panelproxy.setStyle('backgroundColor', initiateur.getStyle('backgroundColor'));
      //panelproxy = initiateur;
      DragManager.doDrag(initiateur, source, e, panelproxy);
      //initiateur.height = 0;
      }

      private function doDragEnter(event:DragEvent):void
      {
      var cibleDeposer:VBox = VBox(event.currentTarget);
      var source:Panel = Panel(event.dragSource);
      if (event.dragSource.hasFormat('panneau'))
      {
      DragManager.acceptDragDrop(cibleDeposer);
      }
      }

      private function doDragDrop(event:DragEvent):void
      {
      var data:Object = event.dragSource.dataForFormat('panneau');
      }
      ]]>
      </mx:Script>
      <mx:HBox x="174" y="156" width="100%">
      <mx:VBox backgroundColor="white" width="25%" height="100%" dragEnter="doDragEnter(event)" dragDrop="doDragDrop(event)">
      <mx:Panel headerColors="[#3333ff, #331166]" width="100%" height="200" layout="absolute" borderStyle="solid" borderColor="#4b4144" title="1" id="pan1" backgroundColor="#af8463" cornerRadius="14" themeColor="#e6dcc5" mouseMove="dragIt(event, 'hello', 'panneau');"/>
      <mx:Panel headerColors="[#3333ff, #33bbbb]" width="100%" height="200" layout="absolute" borderStyle="solid" borderColor="#4b4144" title="2" id="pan2" backgroundColor="#af8463" cornerRadius="14" themeColor="#e6dcc5"/>
      <mx:Panel headerColors="[#33eee, #33ff66]" width="100%" height="200" layout="absolute" borderStyle="solid" borderColor="#4b4144" title="3" id="pan3" backgroundColor="#af8463" cornerRadius="14" themeColor="#e6dcc5"/>
      </mx:VBox>
      <mx:VBox backgroundColor="white" width="25%" height="100%" dragEnter="doDragEnter(event)" dragDrop="doDragDrop(event)">
      <mx:Panel headerColors="[#3333ff, #353f66]" width="100%" height="200" layout="absolute" borderStyle="solid" borderColor="#4b4144" title="4" id="pan7" backgroundColor="#af8463" cornerRadius="14" themeColor="#e6dcc5"/>
      <mx:Panel headerColors="[#0033ff, #33ff66]" width="100%" height="200" layout="absolute" borderStyle="solid" borderColor="#4b4144" title="5" id="pan6" backgroundColor="#af8463" cornerRadius="14" themeColor="#e6dcc5"/>
      </mx:VBox>
      <mx:VBox backgroundColor="white" width="25%" height="100%" dragEnter="doDragEnter(event)" dragDrop="doDragDrop(event)">
      <mx:Panel headerColors="[#1123ff, #334566]" width="100%" height="200" layout="absolute" borderStyle="solid" borderColor="#4b4144" title="6" id="pan8" backgroundColor="#af8463" cornerRadius="14" themeColor="#e6dcc5"/>
      <mx:Panel headerColors="[#3203ff, #33ff66]" width="100%" height="200" layout="absolute" borderStyle="solid" borderColor="#4b4144" title="7" id="pan4" backgroundColor="#af8463" cornerRadius="14" themeColor="#e6dcc5">
      </mx:Panel>
      </mx:VBox>
      <mx:VBox backgroundColor="white" width="25%" height="100%" dragEnter="doDragEnter(event)" dragDrop="doDragDrop(event)">
      <mx:Panel headerColors="[#000000, #33ff66]" width="100%" height="200" layout="absolute" borderStyle="solid" borderColor="#4b4144" title="8" id="pan5" backgroundColor="#af8463" cornerRadius="14" themeColor="#e6dcc5"/>
      </mx:VBox>
      </mx:HBox>

      </mx:Application>