anyone can help me? i wan to rotate matching games when the user wrong pairs.
package {
import flash.display.;
import flash.events.;
import flash.geom.Matrix;
public class MatchingGame extends MovieClip {
private static const cardHorizontalSpacing:Number = 52;
private static const cardVerticalSpacing:Number = 52;
private static const boardOffsetX:Number = 120;
private static const boardOffsetY:Number = 45;
private var firstCard:Card;
private var secondCard:Card;
private var cardsLeft:uint;
public function MatchingGame():void {
}
public function Easy():void{
Title.visible = false;
btn_easy.visible = false;
btn_INT.visible = false;
var cardlist:Array = new Array();
for(var i:uint=0;i<16/2;i++) {
cardlist.push(i);
cardlist.push(i);
}
cardsLeft = 0;
for(var x:uint=0;x<4;x++){
for (var y:uint=0;y<4;y++){
var c:Card = new Card();
c.stop();
c.x = x*cardHorizontalSpacing+boardOffsetX;
c.y = y*cardVerticalSpacing+boardOffsetY;
var r:uint = Math.floor(Math.random()*cardlist.length);
c.cardface = cardlist[r];
cardlist.splice(r,1);
c.addEventListener(MouseEvent.CLICK,clickCard);
addChild(c);
//rotate(cardface,200,-.1,45);
cardsLeft++;
}
}
}
public function clickCard(event:MouseEvent){
var cardArray = new Array();
var thisCard:Card = (event.target as Card);
if(firstCard == null){
firstCard = thisCard;
firstCard.gotoAndStop(thisCard.cardface+2);
}else if(firstCard == thisCard){
firstCard.gotoAndStop(1);
firstCard = null;
}else if(secondCard == null){
secondCard=thisCard;
secondCard.gotoAndStop(thisCard.cardface+2);
if(firstCard.cardface == secondCard.cardface){
removeChild(firstCard);
removeChild(secondCard);
firstCard = null;
secondCard = null;
cardsLeft -= 2; // 2 less cards
if(cardsLeft == 0) {
gotoAndStop("gameover");
}
}
}else{
firstCard.gotoAndStop(1);
secondCard.gotoAndStop(1);
secondCard = null;
firstCard = thisCard;
firstCard.gotoAndStop(thisCard.cardface+2);
}
}
}
}