Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7659275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:18:41+00:00 2026-05-31T13:18:41+00:00

I have a memory game here. And each time a card is removed from

  • 0

I have a memory game here. And each time a card is removed from the gameboard I have “cardCount -2”, when this cardCount gets to zero, I want the program to jump to the next frame which is like a “game over” page. I’ve tried using gotoAndStop(); as well as nextFrame(); but it doesn’t seem to be working!

On my frame 1 I have the game, and on frame 2 I have the gameover page.

Any help would be GREATLY appreciated! Thank you!

Here is my code!

package {
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.display.MovieClip;

public class MemoryGame extends Sprite{

    private var firstTile:cards;
    private var secondTile:cards;
    private var pauseTimer:Timer;
    private var levelTimer:Timer;
    private var score:int;
    private var cardCount:int;




    var numberDeck:Array = new Array(1,1,2,2,3,3,4,4,5,5,6,6);


    public function MemoryGame(){
        score = 0;
        txtScore.text=": "+score;


        for(x=1; x<=4; x++) {
            for (y=1; y<=3; y++){
                var randomCard = Math.floor(Math.random()*numberDeck.length);
                var tile:cards = new cards();
                tile.card = numberDeck[randomCard];
                numberDeck.splice(randomCard,1);
                tile.gotoAndStop(9);
                tile.x = (x-1) * 150;
                tile.y = (y-1) * 200;
                tile.addEventListener(MouseEvent.CLICK,tileClicked);
                addChild(tile);
                cardCount = cardCount + 1

                if (cardCount == 0){
            trace("GAME OVER!")
            trace("SCORE:" +score);
        }


            }
        }
        trace("Cardcount: "+cardCount);
    }

    public function tileClicked(event:MouseEvent) {
        var clicked:cards = (event.currentTarget as cards);
        if (firstTile == null){
            firstTile = clicked;
            firstTile.gotoAndStop(clicked.card);
        }
        else if (secondTile == null && firstTile != clicked){
            secondTile = clicked;
            secondTile.gotoAndStop(clicked.card);
            if (firstTile.card == secondTile.card){
                pauseTimer = new Timer(1000, 1);
                pauseTimer.addEventListener(TimerEvent.TIMER_COMPLETE,removeCards);
                pauseTimer.start();

            }
            else {
                pauseTimer = new Timer(1000, 1);
                pauseTimer.addEventListener(TimerEvent.TIMER_COMPLETE,resetCards);
                pauseTimer.start();
            }
        }

    }

    public function resetCards(event:TimerEvent) {

        firstTile.gotoAndStop(9);
        secondTile.gotoAndStop(9);
        firstTile = null;
        secondTile = null;
        pauseTimer.removeEventListener(TimerEvent.TIMER_COMPLETE,resetCards);
        score = score - 2;
        txtScore.text=": "+score;
    }

    public function removeCards(event:TimerEvent){

        removeChild(firstTile);
        removeChild(secondTile);
        firstTile = null;
        secondTile = null;
        pauseTimer.removeEventListener(TimerEvent.TIMER_COMPLETE,removeCards);
        score = score + 10;
        txtScore.text=": "+score;
        cardCount = cardCount - 2;
        trace("Cardcount: " + cardCount);

        if (cardCount == 0){
            //NEXT FRAME CODE HERE!
            trace("GAME OVER!")
            trace("SCORE:" +score);
        }

                }


}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:18:42+00:00Added an answer on May 31, 2026 at 1:18 pm

    Try to extend MemoryGame from MovieClip , not from Sprite.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ignoring unsafe code, .NET cannot have memory leaks. I've read this endlessly from many
I have a memory game program and when the timer runs out, I want
For my assignment I have to put make a card memory game that allows
I'm making the memory game concentration. In this I have a specified obligation to
I am attempting to make a memory card matching game known as Concentration. So
Say I'd like to make a memory/pairs game. I have currently made a draft
I have source code for a project that inspects a game's memory values. The
I have this method in an exterior class that gets called whenever the charachter
I want to save up memory for my game and I wanted to ask
ok well i have a simple game that uses really high of memory and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.