3 Replies Latest reply on Jan 6, 2014 10:31 AM by kglad

    Graphics not displaying on stage - errors 1119 and 1061

    RunForestRun

      I've been following a tutorial for a simple animation but I'm failing to get the library items to display on the stage. It's probably something really simple. Here is the code in my Main.as

       

      I also receive the errors 1119 and 1061.

       

      If anyone can help that would be fab and much appreciated.

       

       

       

       

      package {

       

       

                import flash.display.MovieClip;

                import flash.events.Event;

       

       

                public class Main extends MovieClip {

       

                          var touching:Boolean = false;

       

                          public function Main() {

       

       

                                    startGame();

                          }

       

                          function startGame():void {

       

                                    stage.addEventListener(Event.ENTER_FRAME, gameLoop);

       

       

                          }

       

                          function gameLoop(e:Event):void {

       

                                    fly();

                                    checkCollisions();

                          }

       

       

                          function fly():void {

       

                                    if (touching == false) {

                                              player.x ==30;

                                    } else if (touching == true) {

                                              stage.removeEventListener(Event.ENTER_FRAME, gameLoop);

                                    }

                          }

       

                          function checkCollisions():void {

       

                                    if (player.hitTestObject(square)) {

                                              touching = true;

                                    } else {

                                              touching = false;

                                    }

                          }

                }

      }

        • 1. Re: Graphics not displaying on stage - errors 1119 and 1061
          kglad Adobe Community Professional & MVP

          no code will execute after a runtime error so you need to correct those errors.

           

          from http://www.amazon.com/gp/product/1435460200/ref=s9_simh_gw_p14_d10_i1?pf_rd_m=ATVPDKIKX0DE R&pf_rd_s=center-2&pf_rd_r=05GGX5SPNP3PXMSX0XKX&pf_rd_t=101&pf_rd_p=1688200382&pf_rd_i=507 846

           

          1061: Call to a possibly undefined method xxxx through a reference with static type flash.display:DisplayObject.

          You are trying to reference a method defined on a MovieClip timeline using dot notation but the Flash compiler does not recognize that MovieClip as a MovieClip. To remedy explicitly cast the MovieClip.

          For example, you have a function/method xxxx() defined on your root timeline which you are trying to reference using,

           

          root.xxxx();

           

          To remedy, cast root as a MovieClip,

          MovieClip(root).xxxx();

           

          1119: Access of possibly undefined property xxx through a reference with static type yyyy

          You're trying to reference a property that doesn't exist for that class type.  You either have a typo or, if the Flash type is something like DisplayObject and, you are trying to reference a property of a class, which does have the property you are trying to reference, explicitly cast your object.

          For example, if you have a DisplayObject (eg, dobj) added to the root timeline:

           

          root.dobj;  // may trigger a 1119 error

           

          MovieClip(root).dobj; // will not trigger a 1119 error

          In fact, almost always when you use root in ActionScript 3 you will need to case it as a MovieClip unless you have a document class that extends the Sprite class. In that situation, you will need to cast root as a Sprite:

          MovieClip(root); // or

          Sprite(root):

          Also if, this.parent is a MovieClip:

           

          this.parent.ivar;  // may trigger a 1119 error

           

          MovieClip(this.parent).ivar;  // will not trigger a 1119

           

          If you're using one of your own class objects,

          var opBtnParent:Sprite = new Sprite();

          addChild(opBtnParent);

          for (var i:int=0;i<4;i++) {

                 var opBtn:Btn_operator = new Btn_operator();

                 opBtnParent.addChild(opBtn);

          }

          // then you can use:

          for (i=0;i<opBtnParent.numChildren;i++) {

                 Btn_operator(opBtnParent.getChildAt(i)).mouseEnabled = false;

          }

          Or, you may be trying to reference an object created outside the class.  In that situation make sure your class is dynamic, for example:

          dynamic public class YourClass extends MovieClip{

          You can now add properties to YourClass instances from outside YourClass.

          • 2. Re: Graphics not displaying on stage - errors 1119 and 1061
            RunForestRun Level 1

            Thanks very much for this. Still confused. I think I removed the errors by changing the class name.

             

            Looks like a good book you've linked to.

            • 3. Re: Graphics not displaying on stage - errors 1119 and 1061
              kglad Adobe Community Professional & MVP

              you're welcome.

               

              (and thanks for the book compliment!)