# Memory Game

**URL:** <https://forum.kirupa.com/t/memory-game/187127>\
**Category:** Uncategorized\
**Created:** [April 26, 2006, 8:59pm UTC](https://forum.kirupa.com/t/memory-game/187127 "2006-04-26T20:59:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![NS05](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ns05/32/2205_2.png) [@NS05](https://forum.kirupa.com/u/NS05)\
**Post date:** [April 26, 2006, 8:59pm UTC](https://forum.kirupa.com/t/memory-game/187127/1 "2006-04-26T20:59:34Z")

</div>

[FONT=Times New Roman][SIZE=3]Hello,[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]I am trying to do a simple Memory Game in Flash 8. The examples I have found are much more complicated than what this game needs to be so I was trying to create my own from scratch. There is no random needed just 8 cards on the screen so 4 matches total. When they get a match the pair visibility turns off and when they are all matched it goes to a finished screen. I have all of that working great but I am having 2 problems.[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]Problem 1:[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]When the user selects the wrong card that isn’t a match I need it to flip back over and set the variables back to 0. I can’t figure out how to do this without writing a conditional statement for each possible order the user could select them in.[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]Problem 2:[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]When they select the second card and it is a match the match disappears which is good but it goes so quickly that the user doesn’t even have time to see that they got the match. I would like it to delay so it doesn’t disappear so fast.[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]I would really appreciate any help here. I have attached the FLA file so you can look at the functionality.[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]Thanks so much!!![/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]Movie Clips On Stage[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]card1a[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]card1b[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]card2a[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]card2b[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]card3a[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]card3b[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]card4a[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]card4b[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]card1a matches with card1b[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]card2a matches with card2b[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]card3a matches with card3b[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]card4a matches with card4b[/SIZE][/FONT]

[CENTER]**[SIZE=3][FONT=Times New Roman]Actions on Root Level[/FONT][/SIZE]**[/CENTER]

**[SIZE=3][FONT=Times New Roman]On Frame 1:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]\_global.match1=0[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]\_global.match2=0[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]\_global.match3=0[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]\_global.match4=0[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]On Frame 5:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]card1a.onRelease = function() {[/SIZE][/FONT]  
[SIZE=3][FONT=Times New Roman]\_root.card1a.play();[/FONT][/SIZE]  
[FONT=Times New Roman][SIZE=3]};[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]card1b.onRelease = function() {[/SIZE][/FONT]  
[SIZE=3][FONT=Times New Roman]\_root.card1b.play();[/FONT][/SIZE]  
[FONT=Times New Roman][SIZE=3]};[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]card2a.onRelease = function() {[/SIZE][/FONT]  
[SIZE=3][FONT=Times New Roman]\_root.card2a.play();[/FONT][/SIZE]  
[FONT=Times New Roman][SIZE=3]};[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]card2b.onRelease = function() {[/SIZE][/FONT]  
[SIZE=3][FONT=Times New Roman]\_root.card2b.play();[/FONT][/SIZE]  
[FONT=Times New Roman][SIZE=3]};[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]card3a.onRelease = function() {[/SIZE][/FONT]  
[SIZE=3][FONT=Times New Roman]\_root.card3a.play();[/FONT][/SIZE]  
[FONT=Times New Roman][SIZE=3]};[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]card3b.onRelease = function() {[/SIZE][/FONT]  
[SIZE=3][FONT=Times New Roman]\_root.card3b.play();[/FONT][/SIZE]  
[FONT=Times New Roman][SIZE=3]};[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]card4a.onRelease = function() {[/SIZE][/FONT]  
[SIZE=3][FONT=Times New Roman]\_root.card4a.play();[/FONT][/SIZE]  
[FONT=Times New Roman][SIZE=3]};[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]card4b.onRelease = function() {[/SIZE][/FONT]  
[SIZE=3][FONT=Times New Roman]\_root.card4b.play();[/FONT][/SIZE]  
[FONT=Times New Roman][SIZE=3]};[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]On Frame 6:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]if ((\_global.match1 == 2) && (\_global.match2 == 2) && (\_global.match3 == 2) && (\_global.match4 == 2)) {[/SIZE][/FONT]  
[SIZE=3][FONT=Times New Roman]\_root.gotoAndPlay(10);[/FONT][/SIZE]  
[FONT=Times New Roman][SIZE=3]} else {[/SIZE][/FONT]  
[SIZE=3][FONT=Times New Roman]\_root.gotoAndPlay(\_currentframe-1);[/FONT][/SIZE]  
[FONT=Times New Roman][SIZE=3]}[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]if (\_global.match1 == 2) {[/SIZE][/FONT]  
[SIZE=3][FONT=Times New Roman]card1a.\_visible = false;[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]card1b.\_visible = false;[/FONT][/SIZE]  
[FONT=Times New Roman][SIZE=3]}[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]if (\_global.match2 == 2) {[/SIZE][/FONT]  
[SIZE=3][FONT=Times New Roman]card2a.\_visible = false;[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]card2b.\_visible = false;[/FONT][/SIZE]  
[FONT=Times New Roman][SIZE=3]}[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]if (\_global.match3 == 2) {[/SIZE][/FONT]  
[SIZE=3][FONT=Times New Roman]card3a.\_visible = false;[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]card3b.\_visible = false;[/FONT][/SIZE]  
[FONT=Times New Roman][SIZE=3]}[/SIZE][/FONT]

[FONT=Times New Roman][SIZE=3]if (\_global.match4 == 2) {[/SIZE][/FONT]  
[SIZE=3][FONT=Times New Roman]card4a.\_visible = false;[/FONT][/SIZE]  
[SIZE=3][FONT=Times New Roman]card4b.\_visible = false;[/FONT][/SIZE]  
[FONT=Times New Roman][SIZE=3]}[/SIZE][/FONT]

[CENTER]**[SIZE=3][FONT=Times New Roman]Actions within Movie Clips[/FONT][/SIZE]**[/CENTER]

**[SIZE=3][FONT=Times New Roman]card1a[/FONT][/SIZE]**  
**[SIZE=3][FONT=Times New Roman]Frame 1:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]stop();[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]Frame 5:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]\_global.match1 = (\_global.match1) + 1[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]trace(\_global.match1);[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]stop();[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]Frame 10:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]\_global.match1 = (\_global.match1) - 1[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]trace(\_global.match1);[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]card1b[/FONT][/SIZE]**  
**[SIZE=3][FONT=Times New Roman]Frame 1:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]stop();[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]Frame 5:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]\_global.match1 = (\_global.match1) + 1[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]trace(\_global.match1);[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]stop();[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]Frame 10:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]\_global.match1 = (\_global.match1) - 1[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]trace(\_global.match1);[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]card2a[/FONT][/SIZE]**  
**[SIZE=3][FONT=Times New Roman]Frame 1:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]stop();[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]Frame 5:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]\_global.match2 = (\_global.match2) + 1[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]trace(\_global.match2);[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]stop();[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]Frame 10:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]\_global.match2 = (\_global.match2) - 1[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]trace(\_global.match2);[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]card2b[/FONT][/SIZE]**  
**[SIZE=3][FONT=Times New Roman]Frame 1:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]stop();[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]Frame 5:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]\_global.match2 = (\_global.match2) + 1[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]trace(\_global.match2);[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]stop();[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]Frame 10:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]\_global.match1 = (\_global.match2) - 1[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]trace(\_global.match2);[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]card3a[/FONT][/SIZE]**  
**[SIZE=3][FONT=Times New Roman]Frame 1:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]stop();[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]Frame 5:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]\_global.match3 = (\_global.match3) + 1[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]trace(\_global.match3);[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]stop();[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]Frame 10:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]\_global.match3 = (\_global.match3) - 1[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]trace(\_global.match3);[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]card3b[/FONT][/SIZE]**  
**[SIZE=3][FONT=Times New Roman]Frame 1:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]stop();[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]Frame 5:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]\_global.match3 = (\_global.match3) + 1[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]trace(\_global.match3);[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]stop();[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]Frame 10:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]\_global.match3 = (\_global.match3) - 1[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]trace(\_global.match3);[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]card4a[/FONT][/SIZE]**  
**[SIZE=3][FONT=Times New Roman]Frame 1:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]stop();[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]Frame 5:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]\_global.match4 = (\_global.match4) + 1[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]trace(\_global.match4);[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]stop();[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]Frame 10:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]\_global.match4 = (\_global.match4) - 1[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]trace(\_global.match4);[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]card4a[/FONT][/SIZE]**  
**[SIZE=3][FONT=Times New Roman]Frame 1:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]stop();[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]Frame 5:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]\_global.match4 = (\_global.match4) + 1[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]trace(\_global.match4);[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]stop();[/SIZE][/FONT]

**[SIZE=3][FONT=Times New Roman]Frame 10:[/FONT][/SIZE]**  
[FONT=Times New Roman][SIZE=3]\_global.match4 = (\_global.match4) - 1[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3]trace(\_global.match4);[/SIZE][/FONT]
