4 Replies Latest reply on May 8, 2010 9:53 AM by ForTheLoss

    Document Class x / y Properties Question

    ForTheLoss

      Hey guys.

       

      I've been working on a project in Flash CS3 for a while.  To follow an object on the screen and keep it centered, I'd adjust the Document Class' x and y properties.

       

      Yesterday I bought/installed Flash CS5 and thus Flash Player 10 was also installed.  Now when I go play my SWF it seems everything is all buggy, as if the code that modifies the Document Class' x and y properties isn't exactly working properly...

       

      I've since reopened the CS3 FLA in CS5 and converted it to a CS5 format and I can't seem to get it working the way it used to.

       

      Did something change regarding the Document Class and how to modify the x / y properties of it in the Flash Player 10 version?  I really don't know what's going on at this point.

       

      Thanks for any help.

        • 1. Re: Document Class x / y Properties Question
          kglad Adobe Community Professional & MVP

          it's a bad idea to change any non-user defined properites of the document class.  why would you do such a thing?

          • 2. Re: Document Class x / y Properties Question
            ForTheLoss Level 1

            Well that's how I was keeping the stage centered on the player.  It was actually suggested to me from someone else a few months ago.  Like I said, it was working perfectly fine until I tried the swf in Flash Player 10.

             

            What other method can I use to keep the screen following an object?  I know there's the vCam, but that's not optimized for games, it causes lag problems.

             

            Theres also the "move everything else on the stage in the opposite direction of the player" method, but, there's no way I'm going to implement something like that so late in the game.

            • 3. Re: Document Class x / y Properties Question
              ForTheLoss Level 1

              Sorry, but I'm starting to pull my hair out here.  Here is the bit of code in question.  This code is in a loop in an instance of the HUD class.  The "parent" of the HUD class is the Document Class:

               

               

              if (player.x < -600)
              {
                   parent.x = 1000;
                   texture.x = -600;
              }
              else if (player.x > 1400)
              {
                   parent.x = -1000;
                   texture.x = 1400;
              }
              else
              {
                   parent.x = (player.x-stage.stageWidth/2)*-1;
                   texture.x = player.x;
              }
              if (player.y < -950)
              {
                   parent.y = 1175;
                   texture.y = -950;
              }
              else if (player.y > 1400)
              {
                   parent.y = -1175;
                   texture.y = 1400;
              }
              else
              {
                   parent.y = (player.y-stage.stageHeight/2)*-1;
                   texture.y = player.y;
              }

               

               

              For some reason, it's not working like it used to.  It's hard to explain other than things are buggy.  Player hitting invisible walls, hittests not working when player actually hitting real walls, etc...  I've had this same problem before and I fixed it so I know this is the code that's doing it.  Just, I don't know what's causing the issue here other than Flash Player 10 not liking it...

               

              Is that even possible?  Between Flash Player 9/10 a selection of code is "interpreted" differently?

              • 4. Re: Document Class x / y Properties Question
                kglad Adobe Community Professional & MVP

                show the first few lines of the HUD class up to and including the contructor and do the same for your document class.