2 Replies Latest reply on Sep 23, 2006 11:10 AM by devunit

    FLash 7 vs 8 , AS 2.0 script

    devunit
      Can anyone give me an idea why this script will work in Flash 7 , but gives the error code in Flash 8?

      on (release, keyPress "<Enter>") {
      if (user add pass eq "xxxxx" add "xxxxx!") {
      gotoAndPlay("Scene 5", 3);
      } else if (user add pass ne "xxxxx" add "xxxxx!") {
      gotoAndPlay("tryagain", 1);
      }
      }

      Here's the error message

      **Error** Scene=animated opening, layer=Layer 3, frame=6:Line 2: ')' expected
      if (user add pass eq "xxxxx" add "xxxxx") {

      **Error** Scene=animated opening, layer=Layer 3, frame=6:Line 3: Statement must appear within on handler
      gotoAndPlay("Scene 5", 3);

      **Error** Scene=animated opening, layer=Layer 3, frame=6:Line 4: Unexpected '}' encountered
      } else if (user add pass ne "xxxxx" add "xxxxx!") {

      Thanks!
        • 1. Re: FLash 7 vs 8 , AS 2.0 script
          Level 7
          the add, eq and ne keywords don't exist in AS2. They were marked
          deprecated in MX 2004, and appearantly gotten rid of in 8.

          add is now + or the String .concat() method
          eq is now == or ===
          ne is now != or !==


          What you want is:

          on (release, keyPress "<Enter>") {
          if (user + pass == "xxxxx" + "xxxxx!") {
          gotoAndPlay("Scene 5", 3);
          } else if (user + pass != "xxxxx" + "xxxxx!") {
          gotoAndPlay("tryagain", 1);
          }
          }

          BTW: The second condition can even be removed entirely. If the first
          condition is not true, the second will always be true. So:

          on (release, keyPress "<Enter>") {
          if (user + pass == "xxxxx" + "xxxxx!") {
          gotoAndPlay("Scene 5", 3);
          } else {
          gotoAndPlay("tryagain", 1);
          }
          }

          Will suffice.

          Manno

          devunit wrote:
          > Can anyone give me an idea why this script will work in Flash 7 , but gives the
          > error code in Flash 8?
          >
          > on (release, keyPress "<Enter>") {
          > if (user add pass eq "xxxxx" add "xxxxx!") {
          > gotoAndPlay("Scene 5", 3);
          > } else if (user add pass ne "xxxxx" add "xxxxx!") {
          > gotoAndPlay("tryagain", 1);
          > }
          > }
          >
          > Here's the error message
          >
          > **Error** Scene=animated opening, layer=Layer 3, frame=6:Line 2: ')' expected
          > if (user add pass eq "xxxxx" add "xxxxx") {
          >
          > **Error** Scene=animated opening, layer=Layer 3, frame=6:Line 3: Statement
          > must appear within on handler
          > gotoAndPlay("Scene 5", 3);
          >
          > **Error** Scene=animated opening, layer=Layer 3, frame=6:Line 4: Unexpected
          > '}' encountered
          > } else if (user add pass ne "xxxxx" add "xxxxx!") {
          >
          > Thanks!
          >

          --
          ----------
          Manno Bult
          manno@xs4all.nl
          • 2. Re: FLash 7 vs 8 , AS 2.0 script
            devunit Level 1
            Manno,

            Thank you for your help and advice.

            Working now.

            Dev