3 Replies Latest reply on Apr 23, 2009 3:17 AM by wvxvw

    Is it possible to drag from html page to flex?

    _Natasha_ Level 4

      I need to emulate drag&drop from html page to flex application which is a part of this html. I cann't do it!

       

      As an example.

       

      The problem is:

      then I drag somithing on the compoment I get dragEnter Event but I don't get mouseUp and dragDrop events!

      DragCompletes only after mouseUp and mouseClick (all these events I can't receive).

      Is it a bug of SDK or I've missed some moments?

       

       

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:display="flash.display.*"

      mouseOver="onMouseOver(event)">

      <mx:Script>

      <![CDATA[

      import mx.controls.Label;

      import mx.core.DragSource;

      import mx.controls.Alert;

      import mx.managers.DragManager;

      import mx.events.DragEvent;

       

       

       

      private var draggedData:String = "TEST STRING";

      private var drgSource:DragSource;

       

      private var inDrag:Boolean = false;

       

       

       

      private function onMouseOver(event:MouseEvent):void

      {

      if (event != null)

      {

       

           if (event.buttonDown && draggedData != "")

           {

       

                DragManager.doDrag(this, drgSource, event, emptyLabel);

                draggedData = "";

           }

      }

      }

      private function onDragEnter(event:DragEvent):void

      {

      this.getFocus();

      DragManager.acceptDragDrop(tree2);

      DragManager.showFeedback(DragManager.LINK);

      }

      public function onDragHandler(event:DragEvent):void

      {

      Alert.show("DragHandler");

       

      }

      private function onDragComplete(event:DragEvent = null):void

      {

      Alert.show("DragComplete");

      }

       

      private function onMouseUp(event:MouseEvent):void // can't get it!!!

      {

      Alert.show("Mouse Up");

      }

      ]]>

      </mx:Script>

      <mx:Array id="testData">

      <mx:Object label="test21"/>

      <mx:Object label="test22"/>

      <mx:Object label="test23"/>

      <mx:Object label="test24"/>

      </mx:Array>

      <mx:Label id="emptyLabel" text=""/>

      <mx:Tree id="tree2" left="10" right="10" top="10" bottom="10" dataProvider="{testData}" showRoot="false"

      mouseUp="onMouseUp(event)" labelField="label" dragEnter="onDragEnter(event)"

      dragDrop="onDragHandler(event)" dragComplete="onDragComplete(event)"></mx:Tree>

      </mx:Application>

        • 1. Re: Is it possible to drag from html page to flex?
          wvxvw

          I would imagine that if you're not getting muoseUp, then it will be dispatched into JavaScript (since, I guess that the mouse is technically hovering over some <div> which you "drag" from HTML page), then you can tell Flex that "drag-drop" happened.

          Another thing I'd check - see if Event.ACTIVATE is fired when releasing the mouse, not sure if it'll work the same way accross all browser, but, maybe, the SWF will get focus after you release the dragged object.

          1 person found this helpful
          • 2. Re: Is it possible to drag from html page to flex?
            _Natasha_ Level 4

            I really get ACTIVATE event then release mouse button. As a work around it's possible to use this event to stop dragging and set what I need.

            But even If I activate swf via JavaScript on mouseOver Event (so control is active while dragging) events still not dispatched.

             

            Any ideas?

            • 3. Re: Is it possible to drag from html page to flex?
              wvxvw Level 1

              I don't think it is possible as the mouse is actually not released / dragged in the area of flash app (you still have an HTML peace in between - that is the <div> you ware dragging is preventing events delivery). So, I think you'll have to use some sort of workaround either way...