5 Replies Latest reply on May 14, 2006 6:41 PM by kglad

    Need Help With Syntax Error

    ZEO2K Level 1
      Here's my code:
      ["item" + num].gotoAndStop("s2");
      stop ();

      Here's my syntax error:
      **Error** Symbol=sprite 107, layer=Action Layer, frame=1:Line 1: Unexpected '.' encountered
      ["item" + num].gotoAndStop("s2");

      Total ActionScript Errors: 1 Reported Errors: 1

      Wanted to know if I wrote this syntax wrong and if anyone knows how to solve it.
      Thanx!
        • 1. Re: Need Help With Syntax Error
          Level 7
          Well, as the error message is telling you, no period (.) before the
          gotoAndStop.

          Either write:

          gotoAndStop("s2")

          or use:

          this.gotoAndStop("s2")

          which is a less buggy syntax.

          Also, you probably don't need the "stop();" after the first line...
          you're already leaving the rest of that code behind by going to the
          frame labeled "s2".

          ZEO2K wrote:
          > Here's my code:
          > .gotoAndStop("s2");
          > stop ();
          >
          > Here's my syntax error:
          > **Error** Symbol=sprite 107, layer=Action Layer, frame=1:Line 1: Unexpected
          > '.' encountered
          > .gotoAndStop("s2");
          >
          > Total ActionScript Errors: 1 Reported Errors: 1
          >
          > Wanted to know if I wrote this syntax wrong and if anyone knows how to solve
          > it.
          > Thanx!
          >
          • 2. Re: Need Help With Syntax Error
            kglad Adobe Community Professional & MVP
            the syntax is wrong and to resolve the problem we need to know the relative or absolute path from the timeline that contains that code to the object "item"+num. if, for example, the object is on the same timeline as the code, you could use:

            • 3. Re: Need Help With Syntax Error
              ZEO2K Level 1
              Thanks guys for your help. It worked!
              • 4. Re: Need Help With Syntax Error
                Level 7
                Oh... forgot about the square brackets disappearing problem, now that
                I'm reading from the newsgroup. That's REALLY annoying...

                kglad wrote:
                > the syntax is wrong and to resolve the problem we need to know the relative or
                > absolute path from the timeline that contains that code to the object
                > "item"+num. if, for example, the object is on the same timeline as the code,
                > you could use:
                >
                >
                >
                > this["item" + num].gotoAndStop("s2");
                >
                • 5. Re: Need Help With Syntax Error
                  kglad Adobe Community Professional & MVP
                  you're welcome.