4 Replies Latest reply on Aug 10, 2007 9:02 AM by Jeremy00

    SWFLoader & Drag'n'Drop Problem

    Jeremy00
      Hello folks,

      So there is my problem ;

      I made a flex swf, containing manual drag'n'drop of some items from a box to an other box.
      When I run this swf alone, the drag'n'drop works fine.

      Then I created an other swf, which is my main application; it initalizes a bunch of things, and each screens is a swf, like the previous one with drag'n'drop.

      When I get on the screen which loads the swf with drag'n'drop, the startDrag run fine, I can catch an item and drag it, but if I release the mouse button, the item stays stuck on the mouse cursor. To get it move back to its box, I have to move the cursor out of my browser window, or to right click so it looses focus, or something like this.

      Is this a flex bug? Do I have something special to do? Maybe the main application events conflicts with the embedded swf events. I really need help on this, I have already spent some time on it, and I can't figure how to solve this.

      Thanks.
        • 1. Re: SWFLoader & Drag'n'Drop Problem
          Karl_Sigiscar_1971 Level 3

          Why not having a ViewStack controlled by a ToggleButtonBar ?

          This is the way the Flex Store v2.0 is organized.

          You would have a view for each screen and you would certainly get rid of this problem.


          • 2. Re: SWFLoader & Drag'n'Drop Problem
            Jeremy00 Level 1
            Thanks for your quick reply.

            I'm not sure this will help, because actually, what I'm developing is more an application architecture than juste an application.

            People using it would have to set in a config file the swf files of the screens they want to see in the application.
            So, even with a view stack, at launch I would have to check this config file, and to load in the stack each of the swf.

            So the point is, at launch, I don't know in advance which swf I will have to load.
            • 3. Re: SWFLoader & Drag'n'Drop Problem
              Jeremy00 Level 1
              Actually, it seems that the "mouse up" event isn't thrown while dragging. So drag never ends.

              While not dragging, "mouse up" event is launched correctly.

              Is it possible the drag, initiated within the loaded swf, is waiting for a "mouse up" from this swf, but that actually the only "mouse up" event raised comes from the main application, and is not detected by the inner swf?

              I'm quite confused about this. And it's really important I solve this quickly.
              Any help or trail would be greatly appreciated.
              • 4. Re: SWFLoader & Drag'n'Drop Problem
                Jeremy00 Level 1
                Using stage.addEventListener(MouseEvent.MOUSE_UP, mouseUp), the mouse up event is fired during drag ... 3 times. I don't know if this is normal, but this seems weird to me, it should fire only one time, I think.

                Whatever, now that I have this mouse up event, how can I stop the drag process? I found nothing useful in the DragManager interface, but a stopDrag() function on the item I'm dragging (which extends Box).

                The following doesn't work:

                private function mouseUp(event:MouseEvent):void
                {
                if (DragManager.isDragging)
                {
                stopDrag();
                }
                }

                Any idea how to stop the drag process, with what I get here?
                Also, any idea why the mouse event is triggered 3 times?

                Thanks.