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 8708273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:05:28+00:00 2026-06-13T04:05:28+00:00

All right so I have the following code and all it does is put

  • 0

All right so I have the following code and all it does is put 3 solid-colour squares on the screen and one rainbow-coloured one in the bottom-right corner. When the user presses on any of the solid-coloured squares, that spot get filled with the rainbow-coloured one and in the original location of the rainbow goes that square that was clicked. The code works almost perfectly except for one thing. When the user tries to click on a square that is UNDER the rainbow square, it returns a run-time error.

My Code:

i

mport flash.display.DisplayObject;
import flash.ui.Mouse;

var t1:DisplayObject = new mc_1;
var t2:DisplayObject = new mc_2;
var t3:DisplayObject = new mc_3;
var t4:DisplayObject = new mc_4;

var tile:Array = [[t1,t2],[t3,t4]];

var r:int;
var c:int;
var a:int = 50;
var b:int = 50;
var aa:int = 1;
var bb:int = 1;
function reDraw() {
    a = 50;
    b = 50;
    for (r=0;r<2;r++) {
        for (c=0;c<2;c++) {
            tile[r][c].x = a;
            tile[r][c].y = b;
            trace(tile[r][c]);
            stage.addChild(tile[r][c]);
            tile[r][c].addEventListener(MouseEvent.CLICK, go);
            a += 100;
        }
        a = 50;
        b += 100;
    }
}
reDraw();

function go(e:MouseEvent):void {
    trace(e.target);
    //Right:
        if (e.target == tile[aa][bb+1]) {
            tile[aa][bb] = e.target;
            bb += 1;
            tile[aa][bb] = t4;
            reDraw();
            trace("Right");
        }
    //Left:
        else if (e.target == tile[aa][bb-1]) {
            tile[aa][bb] = e.target;
            bb -= 1;
            tile[aa][bb] = t4;
            reDraw();
            trace("Left");
        }
    //Up:
        else if (e.target == tile[aa-1][bb]) {
            tile[aa][bb] = e.target;
            aa -= 1;
            tile[aa][bb] = t4;
            reDraw();
            trace("Up");
        }
    //Down:
        else if (e.target == tile[aa+1][bb]) {
            tile[aa][bb] = e.target;
            aa += 1;
            tile[aa][bb] = t4;
            reDraw();
            trace("Down");
        }
        else trace("FAILED!");
    trace(aa +" " +  bb);
}

The error:

TypeError: Error #1010: A term is undefined and has no properties. at
win_fla::MainTimeline/go()

  • 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-13T04:05:28+00:00Added an answer on June 13, 2026 at 4:05 am

    If you take a look at your code you have this:

    //Down:
        else if (e.target == tile[aa+1][bb]) {
            tile[aa][bb] = e.target;
            aa += 1;
            tile[aa][bb] = t4;
            reDraw();
            trace("Down");
        }
    

    now you can see here that its looking for tile[aa+1] however aa = 1 in the beginning so aa+1 = 2 and tile[2] doesn’t exist or is undefined. You’ll need to change your logic there to something like:

    var tileFound:Boolean = false;
    for(var i:int = 0; i < 2; i++){
        for(var j:int = 0; j < 2; j++){
            if(tile[i][j] == e.target){
                tileFound = true;
                tile[aa][bb] = e.target;
                tile[i][j] = t4;
                if(i > aa) trace ("Right");
                else if(i < aa) trace ("Left");
                if(j > bb) trace ("Bottom");
                else if(j < bb) trace ("Top");
                aa = i;
                bb = j;
                reDraw();
                tileFound = true;
                break;
            }
        }
        if(tileFound) break;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code on http://septicsecurity.com/facebook.html It used to work, but does not work
I have the following code right after my controller class declaration before_filter :load_form, :except
I have the following code: http://jsfiddle.net/YfzbZ/ HTML <dl class=dropdown right> <dt><a>Options</a></dt> <dd> <ul style=display:none;>
So, I have the following line of code, that does a for loop and
I have the following code: ul.myList li{ border-right: 1px dotted #000; } However, on
All right so I tried using the button set. So fair, I have been
Right now we have AD/Exchange to manage all of our users logins/e-mail on-site at
Right now, I have all the employees of my company login to an external
I have two Lists, the firs (right) represents a list of all cars and
I have the following code: public void DriveRecursion(string retPath) { string pattern = @[~#&!%\+\{\}]+;

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.