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

# HitTest card.

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

• ###### 1. Re: HitTest card.

what's trace(this) and trace(card) show?

• ###### 2. Re: HitTest card.

card shows last movieclip in array and trace(this) which one we press the MC

• ###### 3. Re: HitTest card.

and is that what you expect?  if so, and if you placed those trace functions in the correct position, what's the problem?

• ###### 4. Re: HitTest card.

how to check hitTest my previous card?

bcz this condtion i can check only last card in hitTest.

• ###### 5. Re: HitTest card.

use:

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 cArray:Array = [];
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;
cArray.push(card);
}

// 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();
for (var i:Number = 0; i<cArray.length; i++) {
if (this != cardArray[i]) {
if (this.hitTest(cArray[i])) {
// terminate loop?
}
}
}
};
}
}
init();

• ###### 6. Re: HitTest card.

Hi,

in that game when i move the card that time get new xpose that time another card should  be shift to previouse xpose.

Thanks,

JaxNa

• ###### 7. Re: HitTest card.

i didn't understand your last post.

but, if the hittest is working the way you want, mark that answer as correct.  if it's not working, leave another message.

• ###### 8. Re: HitTest card.

when we play rummy cards that time darg 1 card and play card move animation exactly i want to do this.

• ###### 9. Re: HitTest card.

are you asking how to animate playing cards?

• ###### 10. Re: HitTest card.

yes.

• ###### 11. Re: HitTest card.

you want the cards to animate like that?

• ###### 12. Re: HitTest card.

http://www.games24x7.com/Welcome.do

I want the cards to animate like that.

• ###### 13. Re: HitTest card.

i can't see that without registering and i'm not going to register.

• ###### 14. Re: HitTest card.

and play a practice tournament.

• ###### 15. Re: HitTest card.

my animation is better.  but, you can use the flash tween class or any third party tween class for that.