1 Reply Latest reply on Dec 12, 2008 11:31 AM by shintashi

    irrational behavior in hit test

    shintashi Level 1

      ok, so I made three modules that were supposed to "snap to" the location when a part of them is dragged over a particular coordinate (in this case I created a grid using square mc's). When releasing the mouse, the object stays and stopdrag switches on for that object. When the object is clicked again, it can be moved out of it's locked position and moved elsewhere.

      The problem is when any of the three objects are locked into place, even though they all have their own interaction with unique movie clip coordinates, the other two cannot be moved. It doesn't matter which of the three is locked into place, the other two also fail to move. I found this very confusing, so I set up three layers on each module to indicate whether it was in drag status, stop drag status, or "locked into place".

      When the following code is used, the items start blinking. Clicking any of them changes the blinking pattern, and sometimes its fast, sometimes its slow, and sometimes it stops. We thought there was a pattern (fast, slow, fast slow, stop) but discovered there really wasn't, and it's probably to due with the synchronization.

      My big issue is WHY are the other two movie clips/modules locking in place when the third module snaps in place?

      --------------------------------------



      var paleos = -1;
      //red
      var andromeda = -1;
      //blue
      var synergy = -1;
      //violet

      onEnterFrame = function(){


      if(paleos==1){
      redpod_mc.gotoAndStop("frame2");
      }else{redpod_mc.gotoAndStop("frame1");
      }

      if(synergy==1){
      violetpod_mc.gotoAndStop("frame2");
      }else{violetpod_mc.gotoAndStop("frame1");
      }

      if(andromeda==1){
      bluepod_mc.gotoAndStop("frame2");
      }else{bluepod_mc.gotoAndStop("frame1");
      }



      if(redpod_mc.hitTest(grid01_mc._x, grid01_mc._y, true) && paleos==1){
      redpod_mc._x = grid01_mc._x;
      redpod_mc._y = grid01_mc._y;
      redpod_mc.stopDrag();
      redpod_mc.gotoAndStop("frame3");
      synergy = synergy * -1;
      andromeda = andromeda * -1;
      }



      if(bluepod_mc.hitTest(grid02_mc._x, grid02_mc._y, true) && andromeda==1){
      bluepod_mc._x = grid02_mc._x;
      bluepod_mc._y = grid02_mc._y;
      bluepod_mc.stopDrag();
      bluepod_mc.gotoAndStop("frame3");
      paleos = paleos * -1;
      synergy = synergy * -1;
      }

      if(violetpod_mc.hitTest(grid03_mc._x, grid03_mc._y, true) && synergy==1){
      violetpod_mc._x = grid03_mc._x;
      violetpod_mc._y = grid03_mc._y;
      violetpod_mc.stopDrag();
      violetpod_mc.gotoAndStop("frame3");
      paleos = paleos * -1;
      andromeda = andromeda * -1;
      }





      }

      redpod_mc.onPress = function(){
      redpod_mc.startDrag();
      paleos = paleos * -1;
      }
      redpod_mc.onRelease = function(){
      redpod_mc.stopDrag();
      }


      violetpod_mc.onPress = function(){
      violetpod_mc.startDrag();
      synergy = synergy * -1;
      }
      violetpod_mc.onRelease = function(){
      violetpod_mc.stopDrag();
      }

      bluepod_mc.onPress = function(){
      bluepod_mc.startDrag();
      andromeda = andromeda * -1;
      }
      bluepod_mc.onRelease = function(){
      bluepod_mc.stopDrag();
      }