2 Replies Latest reply on Mar 30, 2011 5:20 PM by TyTBone

    Script 2 n00b q? (Gary Rosenzweig example platformer)

    TyTBone

      I've been using Flash MX 2004 for a while now to do animation, but I've never been that good with Actionscript. I have some examples from a book my former employer lent me (Gary Rosenzweig's with the fox ), and I've been trying to reconfigure them. Having messed around with the platform example before I can kinda "fudge" my way into adding more elements to levels, making the levels longer, changing the art, etc.

       

      What I'm trying to do is to basically add a "You Win!" frame right now; essentially, when the Fox's position is at a certain point at the grid, you go to a new frame, the "win frame".

       

      But whenever I test it, I always get this error (probably common):

       

      **Error** Scene=Scene 1, layer=Game, frame=2:Line 224: ')' expected
               if (foxPos = x:250,y:0) {

      Total ActionScript Errors: 1      Reported Errors: 1

       

      Here's the function:

       

      function winGame() {
          if (foxPos = x:250,y:0) {
          gotoAndPlay("4");
      }}

       


      I really enjoy Flash and all the possiblities that come with making games (eventually I'd like to get into 3D stuff), but I've never been great with understanding programming and math, so thanks for any help

        • 1. Re: Script 2 n00b q? (Gary Rosenzweig example platformer)
          Ned Murphy Adobe Community Professional & MVP

          I don't know all there is to know about actionscript, but I don't think what you have there is valid code... at least I've never seen anything resembling it in the 10 years or so I've been using Flash.

           

          Try:

           

          function winGame() {
              if (foxPos._x == 250 && foxPos._y == 0) {
                  gotoAndPlay(4);  // no quotes for frame numbers
              }

          }

           

          I guess it really depends on what foxPos.  In any case, if you are comparing something you use == to test for equality

          • 2. Re: Script 2 n00b q? (Gary Rosenzweig example platformer)
            TyTBone Level 1

            Thanks; like I said, I don't understand Actionscript very well nor have the book to research it well.

             

            I replaced the code, and it cleared up any errors. However, nothing seems to happen even when I hit those coordinates (I added a trace to check, and still nothing). I'm wondering if I need to place the function in a specific part of the script (a part of the overall order of functions) or if it needs to be edited to be constantly checking to see if the conditions have been met?