15 Replies Latest reply on Apr 19, 2011 7:02 AM by kglad

    HitTest card.

    JaxNa Level 1

      Hi guys,

       

       

      Can you plz tell me where i am going to wrong? when i drag one card that time check the hit another card and swap the x pose to previous card.

       

      here is my code.

       

      var cardArray:Array = Array("1h", "2h", "3h", "4h", "5h", "6h", "7h", "8h", "9h", "10h", "11h", "12h", "13h", "1s", "2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s", "10s", "11s", "12s", "13s", "1c", "2c", "3c", "4c", "5c", "6c", "7c", "8c", "9c", "10c", "11c", "12c", "13c", "1d", "2d", "3d", "4d", "5d", "6d", "7d", "8d", "9d", "10d", "11d", "12d", "13d");

      var card:MovieClip;

      var randomArray:Array = Array();

      var xpose:Number = 80;

       

      ///create card depend on random No.

      for (var i:Number = 0; i < 13; i++)

      {

      var randomNo = Math.round(Math.random() * (cardArray.length - 1));

      var holdCard:String = cardArray[randomNo];

      _root.card = attachMovie(holdCard, holdCard, this.getNextHighestDepth(), {_y:200});

      randomArray.push(card);

      xpose += 25;

      card._x = xpose;

       

      }

       

      // card Drag and Drop

      function init()

      {

      for (var j = 0; j < randomArray.length; j++)

      {

      card = randomArray[j];

      card.onPress = function()

      {

      startDrag(this);

      };

      card.onRelease = function()

      {

      stopDrag();

      onEnterFrame = function ()

      {

      if (this.hitTest(card))

      {

      trace(this);

      }

      };

      };

      }

      }

      init();

      Thanks,
      JaxNa