9 Replies Latest reply: Jan 19, 2013 4:30 AM by moccamaximum RSS

    1010: A term is undefined and has no properties.

    SimonHenbury

      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

        • 1. Re: 1010: A term is undefined and has no properties.
          Rothrock Community Member

          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.

          • 2. Re: 1010: A term is undefined and has no properties.
            Ned Murphy MVP

            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.

            • 3. Re: 1010: A term is undefined and has no properties.
              SimonHenbury Community Member

              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?

              • 4. Re: 1010: A term is undefined and has no properties.
                Ned Murphy MVP

                Is that the complete error message that you get or is there more information that you did not copy from it?

                 

                If that's all you get for the message, then it looks like there might be something named update somewhere that is involved with the error.  If you can locate something of that then you should be able to use the trace() function to try to isolate what element is coming up as undefined.

                • 5. Re: 1010: A term is undefined and has no properties.
                  SimonHenbury Community Member

                  That is the whole error message and ok i think the problem lies in the external action script file since there is nothing related to update in the main file.
                  Also sorry for being so bad at AS3 but how do i use trace?

                   

                  Thanks for replying again!

                  • 6. Re: 1010: A term is undefined and has no properties.
                    Ned Murphy MVP

                    No need to apologize... we were all bad at AS3 at some point, and I still am in many respects.

                     

                    The way to use the trace() function is to have is tell you the status of things while your file is executing.

                     

                    So if you can find a function called update in your file(s), what you could do is just insert

                     

                        trace("got this far");

                     

                    before the first line of code inside the function.  When you run the file, the trace output is displayed in the Output panel in Flash.  So if your Output panel shows "got this far" (no quotes) before the error message occurs, you know you haven't reached the line of code that has the problem. 

                     

                    So then you can move that trace down a line and try again, and repeat until you don't see "got this far" anymore.  When you don't see it anymore, the line just before the trace line is where the problem likely lies.

                     

                    At that point, move back before that line and uswe the trace to try to figure out which part of that line is undefined by tracing the objects or properties it uses.  Suppose the line of code is....

                     

                    someMC.aChildMC.property = something;

                     

                    Then before that line you could use...

                     

                    trace(someMC);

                    trace(someMC.aChildMC);

                    trace(someMC.aChildMC.property);

                     

                    And then the out will likely display one or more of them as "undefined".  Whichever is the first undefined one is where you need to focus and figure out why it is undefined.  REfer to Rothrock's suggestions for some reasons why it might be.

                    • 7. Re: 1010: A term is undefined and has no properties.
                      SimonHenbury Community Member

                      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.

                      • 8. Re: 1010: A term is undefined and has no properties.
                        SimonHenbury Community Member

                        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[i].update();

                                                      }

                         

                                                      //Update bullets

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

                                                      {

                                                                bullets[i].update();

                         

                                                                if (bullets[i].notInScreen())

                                                                {

                                                                          mcGameStage.removeChild(bullets[i]);

                                                                          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[i].hitTestObject(enemies[j].collisionArea))

                                                                          {

                                                                                    //Increase player score

                                                                                    playerScore += enemies[j].getPointsWorth();

                         

                                                                                    //Remove bullet and enemy

                                                                                    mcGameStage.removeChild(bullets[i]);

                                                                                    mcGameStage.removeChild(enemies[j]);

                                                                                    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[j].collisionArea))

                                                                {

                                                                          mcGameStage.removeChild(player);

                                                                          mcGameStage.removeChild(enemies[j]);

                         

                                                                          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);

                                            }

                        • 9. Re: 1010: A term is undefined and has no properties.
                          moccamaximum Community Member

                          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

                          This is a hint that you have a problem with your scopes.

                          Also what sinious said:

                          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.

                          if you did like you were advised, post the new Error message you get. Publish your movie and look in the output window.

                           

                          Instead of your old error messaeg:

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

                               at GameController/update{}

                          you should get now the information at what Line this code fails.

                           

                          Mark the line in your GameController.update function and post it again.