4 Replies Latest reply on May 13, 2006 8:18 AM by NSurveyor

    PLEASE CAN YOU TELL ME WHAT THIS ERROR MEANS?

    SLMHILL Level 1
      The script attached to my button reads:-

      //This script takes the user to Scene 1 when opendoor is released
      on(Release) = function (){
      gotoAndStop("Scene 1", 1);
      };

      The errors in the Output Panel are:-

      **Error** Scene=Scene 2, layer=door, frame=1:Line 2: '{' expected
      on(Release) = function () {

      **Error** Scene=Scene 2, layer=door, frame=1:Line 4: Statement must appear within on handler
      };

      I will be eternally grateful to anyone who can sort me out!!

        • 1. Re: PLEASE CAN YOU TELL ME WHAT THIS ERROR MEANS?
          Level 7
          SLMHILL wrote:
          > The script attached to my button reads:-
          >
          > //This script takes the user to Scene 1 when opendoor is released
          > on(Release) = function (){
          > gotoAndStop("Scene 1", 1);
          > };
          >
          > The errors in the Output Panel are:-
          >
          > **Error** Scene=Scene 2, layer=door, frame=1:Line 2: '{' expected
          > on(Release) = function () {
          >
          > **Error** Scene=Scene 2, layer=door, frame=1:Line 4: Statement must appear
          > within on handler
          > };
          >
          > I will be eternally grateful to anyone who can sort me out!!
          >
          >
          >

          SLMHILL,

          You're mixing two ways of writing event handlers. If you want to attach
          the script to your button directly, use this code:

          on(Release) {
          gotoAndStop("Scene 1", 1)
          }

          Or, if you want to place all of the scripting in one place, on a frame
          on the main timeline, you would use the code below.

          opendoor.onRelease = function (){
          gotoAndStop("Scene 1", 1);
          };

          To do this, make sure your button on the stage has an instance name of
          "opendoor" -- instance name is in the Properties panel.

          Then make a new layer called "actions" and make sure to click on it in
          the timeline, then open the Actions panel and write the code.
          • 2. Re: PLEASE CAN YOU TELL ME WHAT THIS ERROR MEANS?
            blemmo Level 1
            Don't confuse the on(xxx) handlers with the onXXX events:
            on(release){
            // actions
            }

            vs.

            onRelease = function(){
            // actions
            }

            The on(xxx) handlers have to be bound to an object directly (placed in the code attached to an instance), the onXXX events have to be placed in the timeline, and normally have the instance they are bound to specified in dot syntax, like
            button1.onRelease = ...

            greets,
            blemmo
            • 3. Re: PLEASE CAN YOU TELL ME WHAT THIS ERROR MEANS?
              SLMHILL Level 1
              Thanks, I'll try again
              • 4. Re: PLEASE CAN YOU TELL ME WHAT THIS ERROR MEANS?
                NSurveyor Level 2
                Also note that using scenes with gotoAndPlay/Stop is buggy. It has been advised by many to use the MovieClip method, along with frame labels. In your case, all you would need is:

                _root.gotoAndStop(1);