4 Replies Latest reply on Sep 30, 2006 7:58 PM by abeall

    Dragging across SWFs using localConnection

    chardwick99 Level 1
      Hello all,

      I have two SWF's communicating via localConnection. Uers drag items from one SWF to the other, and I have the receiving SWF attach a clip and set its ._x and ._y to _xmouse and _ymouse, completing the illusion of seamless drag. However I'm having trouble getting Flash to recognize a MouseDown event when the mouse is already down upon focus. Currently I'm using onMouseMove to trigger this (since onMouseDown will not work) and it will only trigger once the mouse is released. How can I get Flash to recognize a mousDown event that's already occurring upon entering the SWF? It seems as though Flash knows some of what's going on, because since the mouse is displaying a hand cursor upon focus, some event has been registered, and the function itself is accessed but balks at attaching and positioning the clip. Here is a simplified version of what I'm trying to do:

      Code for swf that I'm dragging from:

      mySender_lc = new LocalConnection();

      drag_mc.onPress = function() {

      drag_mc.onRelease = function() {

      drag_mc.onReleaseOutside = function() {
      _root.mySender_lc.send("myConnection", "myAction");

      Code for SWF I'm dragging TO:

      myReceiver_lc = new LocalConnection();

      myReceiver_lc.myAction = function() {
      trace("function accessed");
      attachMovie("circle_id", "circle_mc", this.getNextHighestDepth());
      var mouseListener:Object = new Object();
      mouseListener.onMouseMove = function() {
      _root.circle_mc._x = _xmouse;
      _root.circle_mc._y = _ymouse;
      _root.circle_mc.my_txt="following Mouse onMouseMove";


      and here's an example: http://www.pokerxfactor.com/swf/test/localConnExample.htm

      Any help would definitely be appreciated. Thank you!

      Chris Hardwick
        • 1. Re: Dragging across SWFs using localConnection
          abeall Level 3
          I couldn't really get it to work at all...
          > How can I get Flash to recognize a mousDown event that's already occurring
          > upon entering the SWF?
          I really doubt that is possible. Your closest bet is going to be to use JS to detect the mouse actions, and inform the respective SWFs as to what to do. In other words, tell the SWF that the mouse has left or entered, and wether the mouse is up or down, dragging an object or not, ect.
          • 2. Re: Dragging across SWFs using localConnection
            kglad Adobe Community Professional & MVP
            or set a variable onMouseDown in one swf that's communicated to the other swf so the other can "fake" a mouseDown.
            • 3. Re: Dragging across SWFs using localConnection
              TimSymons Level 1
              I could drag the circle in the opposite direction and then release outside the Flash window and it would appear in the other window but I see what you are getting at. You might want to also define the onDragOut event with your onReleaseOutside event.

              drag_mc.onReleaseOutside = drag_mc.onDragOut = function() {

              Also, I agree with abeall about using JS. You should try to use JS to set the mouse focus to the new Flash movie. Since Flash does not recieve focus by simply moving your mouse over the Flash object, you would have to programmatically set the focus to the second Flash object within the HTML page.

              You might be able to use the onDragOut event to call to things. The first would be the LocalConnection like you are doing now. The second would be to use the FSCommand or the ExternalInterface class to call a JS function to switch focus to the other Flash movie. You could also use the last _xmouse position to determine if the user was dragging the circle toward the other Flash movie or away from it.

              • 4. Re: Dragging across SWFs using localConnection
                abeall Level 3
                Or, use Flash 9 and AS3.0, which can detect if the mouse has left or entered the stage from within Flash(in all previous versions, it's not possible to really tell if the mouse has left the stage, you must use JS which is not very friendly or as well supported by browsers).

                Detecting mouse leave/enter combined with kglad's suggestion of setting properties via LocalConnection and you could fairly easily do everything you need.