Overlapping Problem

  • TvFreak
  • Newbie
  • Newbie
  • TvFreak
  • Posts: 12

Post 3+ Months Ago

Hi all

i hav 10objects dat need to b drag to certain area of hitTests.

For this part of the code i hav 9hitTest.
The user cn drop any1 of the 9avail hittest.

example : if user drop the
objectA to hitTest1,
next user drag objectB and drop at hitTest1 it overlaps.

The problem is:

i want the objects to shoot back at the orginial position if any of the hitTest is occupied.
I want to prevent it frm overlapping.

Help me.
Thank u veri much.

Code: [ Select ]
//***************************************
//Battery
//***************************************
battery_mc.useHandCursor = false;
battery_mc.onPress = function() {
  this.startDrag(false);
  this.onMouseMove = function() {
   updateAfterEvent();
  };
};
//handle release event
battery_mc.onRelease = battery_mc.onReleaseOutside=function () {
  stopDrag();
  this.onMouseMove = undefined;
  if (this.hitTest(_root.dropTarget_mc)) {
   this.gotoAndStop(2);
   this._x = 40;
   this._y = 176.1;
  } else if (this.hitTest(_root.dropTarget2_mc)) {
   this.gotoAndStop(2);
   this._x = 120;
   this._y = 176.1;
  } else if (this.hitTest(_root.dropTarget3_mc)) {
   this.gotoAndStop(2);
   this._x = 200;
   this._y = 176.1;
  } else if (this.hitTest(_root.dropTarget4_mc)) {
   this.gotoAndStop(2);
   this._x = 40;
   this._y = 233.1;
  } else if (this.hitTest(_root.dropTarget5_mc)) {
   this.gotoAndStop(2);
   this._x = 120.0;
   this._y = 233.1;
  } else if (this.hitTest(_root.dropTarget6_mc)) {
   this.gotoAndStop(2);
   this._x = 200;
   this._y = 233.1;
  } else if (this.hitTest(_root.dropTarget7_mc)) {
   this.gotoAndStop(2);
   this._x = 45;
   this._y = 290.1;
  } else if (this.hitTest(_root.dropTarget8_mc)) {
   this.gotoAndStop(2);
   this._x = 120;
   this._y = 290.1;
  } else if (this.hitTest(_root.dropTarget9_mc)) {
   this.gotoAndStop(2);
   this._x = 200.9;
   this._y = 290.1;
  }else {
   this._x = 99.7;
   this._y = 30.2;
   
  }
  if(this.hitTest(_root.dropTarget_mc)||(_root.dropTarget2_mc)
        ||(_root.dropTarget3_mc)||(_root.dropTarget4_mc)
        ||(_root.dropTarget5_mc)||(_root.dropTarget6_mc)
        ||(_root.dropTarget7_mc)||(_root.dropTarget8_mc)
        ||(_root.dropTarget9_mc))
  {
   _root.allCorrect +=0;
  }if(this.hitTest(_root.dropTarget10_mc)||(_root.dropTarget11_mc)
        ||(_root.dropTarget12_mc)||(_root.dropTarget13_mc)
        ||(_root.dropTarget14_mc)||(_root.dropTarget15_mc)
        ||(_root.dropTarget16_mc)||(_root.dropTarget17_mc)
        ||(_root.dropTarget18_mc))
  {
   _root.allCorrect --;
  }
  trace(allCorrect);
};
  1. //***************************************
  2. //Battery
  3. //***************************************
  4. battery_mc.useHandCursor = false;
  5. battery_mc.onPress = function() {
  6.   this.startDrag(false);
  7.   this.onMouseMove = function() {
  8.    updateAfterEvent();
  9.   };
  10. };
  11. //handle release event
  12. battery_mc.onRelease = battery_mc.onReleaseOutside=function () {
  13.   stopDrag();
  14.   this.onMouseMove = undefined;
  15.   if (this.hitTest(_root.dropTarget_mc)) {
  16.    this.gotoAndStop(2);
  17.    this._x = 40;
  18.    this._y = 176.1;
  19.   } else if (this.hitTest(_root.dropTarget2_mc)) {
  20.    this.gotoAndStop(2);
  21.    this._x = 120;
  22.    this._y = 176.1;
  23.   } else if (this.hitTest(_root.dropTarget3_mc)) {
  24.    this.gotoAndStop(2);
  25.    this._x = 200;
  26.    this._y = 176.1;
  27.   } else if (this.hitTest(_root.dropTarget4_mc)) {
  28.    this.gotoAndStop(2);
  29.    this._x = 40;
  30.    this._y = 233.1;
  31.   } else if (this.hitTest(_root.dropTarget5_mc)) {
  32.    this.gotoAndStop(2);
  33.    this._x = 120.0;
  34.    this._y = 233.1;
  35.   } else if (this.hitTest(_root.dropTarget6_mc)) {
  36.    this.gotoAndStop(2);
  37.    this._x = 200;
  38.    this._y = 233.1;
  39.   } else if (this.hitTest(_root.dropTarget7_mc)) {
  40.    this.gotoAndStop(2);
  41.    this._x = 45;
  42.    this._y = 290.1;
  43.   } else if (this.hitTest(_root.dropTarget8_mc)) {
  44.    this.gotoAndStop(2);
  45.    this._x = 120;
  46.    this._y = 290.1;
  47.   } else if (this.hitTest(_root.dropTarget9_mc)) {
  48.    this.gotoAndStop(2);
  49.    this._x = 200.9;
  50.    this._y = 290.1;
  51.   }else {
  52.    this._x = 99.7;
  53.    this._y = 30.2;
  54.    
  55.   }
  56.   if(this.hitTest(_root.dropTarget_mc)||(_root.dropTarget2_mc)
  57.         ||(_root.dropTarget3_mc)||(_root.dropTarget4_mc)
  58.         ||(_root.dropTarget5_mc)||(_root.dropTarget6_mc)
  59.         ||(_root.dropTarget7_mc)||(_root.dropTarget8_mc)
  60.         ||(_root.dropTarget9_mc))
  61.   {
  62.    _root.allCorrect +=0;
  63.   }if(this.hitTest(_root.dropTarget10_mc)||(_root.dropTarget11_mc)
  64.         ||(_root.dropTarget12_mc)||(_root.dropTarget13_mc)
  65.         ||(_root.dropTarget14_mc)||(_root.dropTarget15_mc)
  66.         ||(_root.dropTarget16_mc)||(_root.dropTarget17_mc)
  67.         ||(_root.dropTarget18_mc))
  68.   {
  69.    _root.allCorrect --;
  70.   }
  71.   trace(allCorrect);
  72. };
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

awwwchhh, i`m in pain.
You actually never heard of loop instructions?
then use a variable for the current dragged object ... and when mouse up, test if it`s in the correct position, otherwise bring it back.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 20 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.