Monday, 7 March 2016

CARD PAIR GAME AS2




-------------------------------------------------------------------------------------------------------------------
STEP 1  
1- PLACE 4 IMAGES
2-  PRESS F8 KEY AND  4 IMAGES TO MOVIE CLIP SYMBOLS
3- GIVE INSTANCE NAMES: circle  circle2  square square2 
4- PASTE CODE ON MAIN TIMELINE IN FRAME 1
--------------------------------------------------------------------------------------------------------------------
1- PLACE 4 IMAGES
--------------------------------------------------------------------------------------------------------------------
circle
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------
circle2
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------
square
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------
square2 
---------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------
PASTE CODE ON MAIN TIMELINE IN FRAME 1
---------------------------------------------------------------------------------------------------------------------

// BOOLEAN VARIABLE
var second:Boolean=false;

//SUPPOSE MOVIE CLIP VARIABLES
var firstCard_mc:MovieClip;
var secondCard_mc:MovieClip;

//CIRCLE MOVIE CLIP CODES
circle.onPress = function(){  
circle.gotoAndStop("front");
if(second){
secondCard_mc=this;
if(firstCard_mc.myReference==secondCard_mc.myReference) { trace("CORRECT"); }
else { firstCard_mc.gotoAndStop("back"); secondCard_mc.gotoAndStop("back"); }
second=false;
}
else{
firstCard_mc=this;
second=true;
}
}
//CIRCLE2 MOVIE CLIP CODES
circle2.onPress = function(){  
circle2.gotoAndStop("front");
if(second){
secondCard_mc=this;
if(firstCard_mc.myReference==secondCard_mc.myReference){ trace("CORRECT")}
else {firstCard_mc.gotoAndStop("back");
secondCard_mc.gotoAndStop("back")}
second=false;
}
else{
firstCard_mc=this
second=true}
}

// SQUARE MOVIE CLIP CODE
square.onPress = function(){  
square.gotoAndStop("front");
if(second){
secondCard_mc=this;
if(firstCard_mc.myReference==secondCard_mc.myReference) { trace("CORRECT"); }
else {firstCard_mc.gotoAndStop("back"); secondCard_mc.gotoAndStop("back"); }
second=false;
}
else{
firstCard_mc=this;
second=true;
}}
// SQUARE2 MOVIE CLIP CODE
square2.onPress = function(){  
square2.gotoAndStop("front");
if(second){
secondCard_mc=this;
if(firstCard_mc.myReference==secondCard_mc.myReference) { trace("CORRECT"); }
else { firstCard_mc.gotoAndStop("back"); secondCard_mc.gotoAndStop("back"); }
second=false}
else{
firstCard_mc=this;
second=true;
}
}

-------------------------------------------------------------------------------------------------------------------
STEP 2  
1- PASTE ON CLIP EVENT CODE INSIDE  4 MOVIE CLIP SYMBOLS
-------------------------------------------------------------------------------------------------------------------


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

onClipEvent(load){
gotoAndStop("back");
var myReference:Number = 1;
}
-------------------------------------------------------------------------------------------------------------------



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

onClipEvent(load){
gotoAndStop("back");
var myReference:Number = 2;
}

-------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------
STEP 3
1- MAKE SECOND  INSERT KEY FRAME INSIDE ALL MOVIE CLIP SYMBOLS
2-  GIVE  FRAME LABLE NAMES front back
-------------------------------------------------------------------------------------------------------------------
circle  INSIDE GIVE FRAME LABELS
-------------------------------------------------------------------------------------------------------------------


-------------------------------------------------------------------------------------------------------------------
circle2  INSIDE GIVE FRAME LABELS
-------------------------------------------------------------------------------------------------------------------



-------------------------------------------------------------------------------------------------------------------
square  INSIDE GIVE FRAME LABELS
-------------------------------------------------------------------------------------------------------------------




-------------------------------------------------------------------------------------------------------------------
square2  INSIDE GIVE FRAME LABELS
-------------------------------------------------------------------------------------------------------------------




---------------------------------------------------------------------------------------------------------------------
BLANK IMAGE FOR EACH MOVIE CLIP SYMBOL INSIDE FRAME 2
OR DRAW BOX
---------------------------------------------------------------------------------------------------------------------


--------------------------------------------------------------------------------------------------------------------------
CHANGE ABOVE  GAME IN COLOR MATCHING GAME IN AS2
--------------------------------------------------------------------------------------------------------------------------
MAKE CARD I WITH INSIDE RED FRAME
MAKE CARD 3 WITH INSIDE  GREEN FRAME
GIVE INSTANCE NAMES CARD I  & CARD 3
Card1, Card3
NOW MAKE A COPY OF CARD I  & CARD3  AND GIVE INSTANCE NAMES
Card2, Card4
--------------------------------------------------------------------------------------------------------------------------




--------------------------------------------------------------------------------------------------------------------------
MAIN TIME LINE CODE NO NEED FRAME LABELS
--------------------------------------------------------------------------------------------------------------------------

// BOOLEAN VARIABLE
var second:Boolean=false;

//SUPPOSE MOVIE CLIP VARIABLES
var firstCard_mc:MovieClip;
var secondCard_mc:MovieClip;

//CARD 1 & 2 MOVIE CLIP CODES
Card1.onPress = function(){
Card1.gotoAndStop(2);
if(second){
secondCard_mc=this;
if(firstCard_mc.myReference==secondCard_mc.myReference) { trace("CORRECT"); }
else { firstCard_mc.gotoAndStop(1); secondCard_mc.gotoAndStop(1); }
second=false;
}
else{
firstCard_mc=this;
second=true;
}
}

Card2.onPress = function(){
Card2.gotoAndStop(2);
if(second){
secondCard_mc=this;
if(firstCard_mc.myReference==secondCard_mc.myReference){ trace("CORRECT")}
else {firstCard_mc.gotoAndStop(1);
secondCard_mc.gotoAndStop(1)}
second=false;
}
else{
firstCard_mc=this
second=true}
}

//CARD 3 & 4 MOVIE CLIP CODES
Card3.onPress = function(){
Card3.gotoAndStop(2);
if(second){
secondCard_mc=this;
if(firstCard_mc.myReference==secondCard_mc.myReference) { trace("CORRECT"); }
else {firstCard_mc.gotoAndStop(1); secondCard_mc.gotoAndStop(1); }
second=false;
}
else{
firstCard_mc=this;
second=true;
}}

Card4.onPress = function(){
Card4.gotoAndStop(2);
if(second){
secondCard_mc=this;
if(firstCard_mc.myReference==secondCard_mc.myReference) { trace("CORRECT"); }
else { firstCard_mc.gotoAndStop(1); secondCard_mc.gotoAndStop(1); }
second=false}
else{
firstCard_mc=this;
second=true;
}
}
------------------------------------------------------------------------------------------------------------------
CARD 1 AND CARD 2 INSIDE CODE SAME BECAUSE BOTH ARE COPIES OF EACH OTHER   
-------------------------------------------------------------------------------------------------------------------
onClipEvent(load){
gotoAndStop(1);
var myReference:Number = 1;
}
-------------------------------------------------------------------------------------------------------------------


------------------------------------------------------------------------------------------------------------------
CARD 3 AND CARD 4 INSIDE CODE SAME BECAUSE BOTH ARE COPIES OF EACH OTHER   
-------------------------------------------------------------------------------------------------------------------
onClipEvent(load){
gotoAndStop(1);
var myReference:Number = 2;
}
-------------------------------------------------------------------------------------------------------------------





1 comments:


EmoticonEmoticon