Skip to main content
Participating Frequently
January 18, 2013
Question

1010: A term is undefined and has no properties.

  • January 18, 2013
  • 2 replies
  • 8496 views

TypeError: Error #1010: A term is undefined and has no properties.

     at GameController/update{}

is the error i have been getting

Here is my game = http://www.filehosting.org/file/details/412784/alt.rar

Test 3 is the main document

im not really sure what to do at the moment when i load my game and hit play it works fine for until an enemy appears then i get this error constantly

dont really know how i can explain any better over text

thanks alot

This topic has been closed for replies.

2 replies

Ned Murphy
Legend
January 18, 2013

Go into your Flash Publish Settings and select the option to Permit Debugging.  Then run the file again and review the error message.  That can help by including in the error message the line number where the error occurs.  Once you know which line is involved you can try to use the trace() function to isolate which element is undefined.

Inspiring
January 18, 2013

Go into your flash publish settings and check the box "permit debugging" now the error should tell you what line is causing the problem.

Overall it means that something doesn't exist, have the name you think it does, or is in a different scope at the time that line is trying to do something with it.

Participating Frequently
January 18, 2013

Thanks for replying and permit debugging is on thats what i got. It works fine when its just the game file im trying to add a menu to it so maybe their is a crossover?

Participating Frequently
January 18, 2013

I have a button the uses the code snippet of loading another .swf but the game works fine on its own .swf its when i load it through the menu.swf it goes wrong

im just doing what you suggested of tracing now.


Here is my update function not sure if it helps solve anything

private function update(evt:Event)

                    {

 

                              //******************z

                              //Handle User Input

                              //******************

                              //Handle Player 1 User Input

 

                              if (moveX > 0)

                              {

                                        if (player.x <= C.PLAYER_RIGHT_BOUND)

                                                  player.x += C.PLAYER_SPEED;

                              }

                              else if (moveX < 0)

                              {

                                        if (player.x > C.PLAYER_LEFT_BOUND)

                                                  player.x -= C.PLAYER_SPEED;

                              }

                              if (moveY > 0)

                              {

                                        if (player.y <= C.PLAYER_DOWN_BOUND)

                                                  player.y += C.PLAYER_SPEED;

                              }

                              else if (moveY < 0)

                              {

                                        if (player.y > C.PLAYER_UP_BOUND)

                                                  player.y -= C.PLAYER_SPEED;

                              }

 

                              //Handle Firing of bullets

                              if (fireBullet)

                              {

                                        var currTime = getTimer();

 

                                        if (currTime - lastBulletTime > C.BULLET_DELAY)

                                        {

                                                  lastBulletTime = currTime;

 

                                                  var newBullet = new Bullet(player.x, player.y);

                                                  bullets.push(newBullet);

                                                  mcGameStage.addChild(newBullet);

                                        }

 

                                        fireBullet = false;

                              }

 

                              //******************

                              //Handle Game Logic

                              //******************

                              //Check to spawn new enemies

                              if (Math.random() < C.SPAWN_ENEMY_CHANCE)

                              {

                                        //Create a new monster

                                        var newEnemy = new Enemy();

                                        enemies.push(newEnemy);

                                        mcGameStage.addChild(newEnemy);

                              }

 

                              //Update enemies

                              for (var i=enemies.length - 1; i >= 0; i--)

                              {

                                        enemies.update();

                              }

 

                              //Update bullets

                              for (var i=bullets.length - 1; i >= 0; i--)

                              {

                                        bullets.update();

 

                                        if (bullets.notInScreen())

                                        {

                                                  mcGameStage.removeChild(bullets);

                                                  bullets.splice(i,1);

                                        }

                              }

 

                              //Check for collision

                              //---------------------

                              //Bullet and Enemy collisions

                              for (var i=bullets.length - 1; i >= 0; i--)

                              {

                                        for (var j=enemies.length - 1; j >= 0; j--)

                                        {

                                                  if (bullets.hitTestObject(enemies.collisionArea))

                                                  {

                                                            //Increase player score

                                                            playerScore += enemies.getPointsWorth();

 

                                                            //Remove bullet and enemy

                                                            mcGameStage.removeChild(bullets);

                                                            mcGameStage.removeChild(enemies);

                                                            bullets.splice(i,1);

                                                            enemies.splice(j,1);

 

                                                            break;

                                                  }

                                        }

                              }

 

                              //Player and Enemy collisions

                              for (var j=enemies.length - 1; j >= 0; j--)

                              {

                                        if (player.collisionArea.hitTestObject(enemies.collisionArea))

                                        {

                                                  mcGameStage.removeChild(player);

                                                  mcGameStage.removeChild(enemies);

 

                                                  enemies.splice(j,1);

 

                                                  player = null;

 

                                                  gameOver();

 

                                                  break;

                                        }

                              }

 

                              //******************

                              //Handle Display

                              //******************

                              //Update scrolling of background image

                              mcBackground1.x -= C.SCROLL_SPEED;

                              mcBackground2.x -= C.SCROLL_SPEED;

                              if (mcBackground1.x <= -mcBackground1.width)

                              {

                                        //switch it to the back of background 2

                                        mcBackground1.x = mcBackground2.x + mcBackground2.width;

                              }

                              else if (mcBackground2.x <= -mcBackground2.width)

                              {

                                        //switch it to the back of background 1

                                        mcBackground2.x = mcBackground1.x + mcBackground1.width;

                              }

 

                              //Display new Score

                              txtScorePlayer.text = String(playerScore);

                    }