2 Replies Latest reply on Dec 13, 2010 3:48 PM by robdillon

    1084: Syntax error: expecting rightbrace before end of program.

    Gorrack1129 Level 1

      So I'm doing this basic coding thing to make an object "shoot" bullets. It's from a tutorial video. My code matches his exactly unless I'm missing a tiny detail. Basically the code looks like this:


      package {


      import flash.display.Sprite;


      import flash.events.Event;

       

      public class bullet extends Sprite {

       

      private var sw:Number;
      private var sh:Number;
      private const _SPEED:int=-10;
      private const _OFFSTAGE:int=-10;

       

      public function bullet():void {
      addEventListener(Event.ADDED_TO_STAGE,onadd);
      }

       

      private function onadd(e:Event):void {
      sw=stage.stageWidth;
      sh=stage.stageHeight;
      addEventListener(Event.ENTER_FRAME,loop);
      }

       

      private function loop(e:Event):void {
      if (y<_OFFSTAGE) {
      removeEventListener(Event.ENTER_FRAME,loop);
      parent.removeChild(this);
      }
      y-=_SPEED;
      }public function removeListeners():void {
      removeEventListener(Event.ENTER_FRAME,loop);

       

      }

       

       

      And the compiler error I'm getting says this:
      Location:bullet.as line 31 1084: Syntax error: expecting rightbrace before end of program. Source: }
      Location:bullet.as line 31 1084: Syntax error: expecting rightbrace before end of program. Source: }
      And yes it does say it twice. What's going on?

      The vid I'm learning from is this: http://autocad.spinelink.com/adobe-flash-cs4-game-tutorial-shooting.html

        • 1. Re: 1084: Syntax error: expecting rightbrace before end of program.
          Ned Murphy Adobe Community Professional & MVP

          If what you show is what you have, then the error(s) are teliing you you have some missing braces.  Based on what I see, there are probably 2 missing at the end.  For every { there must be a } somewhere.

          • 2. Re: 1084: Syntax error: expecting rightbrace before end of program.
            robdillon Most Valuable Participant

            You are missing two closing curly braces at the bottom of the package declaration. You need to close the package itself and the class declaration inside.

             

            package {

             

                 import flash.display.Sprite;

                 import flash.events.Event;

             

                 public class bullet extends Sprite {

             

                      private var sw:Number;

                      private var sh:Number;

                      private const _SPEED:int=-10;

                      private const _OFFSTAGE:int=-10;

             

                      public function bullet():void {

                           addEventListener(Event.ADDED_TO_STAGE,onadd);

                      }

             

                      private function onadd(e:Event):void {

                           sw=stage.stageWidth;

                           sh=stage.stageHeight;

                           addEventListener(Event.ENTER_FRAME,loop);

                      }

             

                      private function loop(e:Event):void {

                           if (y<_OFFSTAGE) {

                                removeEventListener(Event.ENTER_FRAME,loop);

                                parent.removeChild(this);

                           }

                           y-=_SPEED;

                      }

             

             

                      public function removeListeners():void {

                           removeEventListener(Event.ENTER_FRAME,loop);

                       }

                }

            }

            1 person found this helpful