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

  • SEARCH
  • Home
  • 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 8786529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:39:09+00:00 2026-06-13T21:39:09+00:00

I am trying to make a simple card matching game via flash + actionscript,

  • 0

I am trying to make a simple card matching game via flash + actionscript, and am having major trouble with assigning event listeners and name. I have got all the card generation statements in place, and they all draw onto my stage, but even though I assigning their instance name with newCard.name, the name I get when tracing the click is always “root1” on every single button, and I have no idea why.

package  {
import flash.display.MovieClip;
import flash.events.MouseEvent;

public dynamic class cardGameMain extends MovieClip {

    public function cardGameMain() {
        addCards();
    }
    public function addCards() {
        var lastCard:int;
        for (var i = 1; i < 17; i++) {
            var newCard:MovieClip;
            newCard = new cardBackSymbol();
            newCard.name = "card" + i;
            addChild(newCard);
            newCard.addEventListener(MouseEvent.MOUSE_UP, decideCard);
            if (i == 1 || i == 5 || i == 9 || i == 13) {
                newCard.x = 20;
                if (i == 1) {
                    newCard.y = 20;
                }
                else if (i == 5) {
                    newCard.y = 240;
                }
                else if (i == 9) {
                    newCard.y = 460;
                }
                else if (i == 13) {
                    newCard.y = 680;
                }
                lastCard = 20;
            } else if (i > 1 && i < 5) {
                newCard.x = lastCard + 145;
                newCard.y = 20;
                lastCard = lastCard + 145;
            } else if (i > 5 && i < 9) {
                newCard.x = lastCard + 145;
                newCard.y = 240;
                lastCard = lastCard + 145;
            } else if (i > 9 && i < 13) {
                newCard.x = lastCard + 145;
                newCard.y = 460;
                lastCard = lastCard + 145;
            } else {
                newCard.x = lastCard + 145;
                newCard.y = 680;
                lastCard = lastCard + 145;
            }
            trace(newCard.name + " position is " + newCard.x + ", " + newCard.y);
        }
    }

    public function decideCard(e:MouseEvent):void {
        trace(this.name)
    }
}

}

Any help on the matter is MUCH appretiated!

  • 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-06-13T21:39:11+00:00Added an answer on June 13, 2026 at 9:39 pm

    You’re using the this keyword which is referring to the containing class, not the object clicked.

    Try this instead:

    public function decideCard(e:MouseEvent):void {
        trace(DisplayObject(e.currentTarget).name)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I'm having a little trouble trying to make a card reader work properly
Trying to make simple minesweeper game in python, but have one problem. I have
I'm trying to make a simple blackjack program. Sadly, I'm having problems right off
Background: Trying to make a simple drop the ball game. The code is located
I am trying to make a simple text-based game in Python. The idea of
I'm trying to make a simple browser game without relying on anything fancy like
I'm trying to make a simple credit card repayment calculator script but seem to
I'm trying to make simple website with content background combined from 3 images: top
I am trying to make simple notepad application for learning android development. So, to
I'm trying to make simple script using jquery $post function to pass data to

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.