3 Replies Latest reply on Feb 15, 2007 4:51 AM by Mac_Guy

    Help with converting AS1 to AS2

    Mac_Guy
      I bought a motion effect from ohmyflash.com. When I opened it in Flash 8, it ran fine, but the Player sttings were set to Flash MX: The player version was set to 6 and the AS version was at 1. When I changed the Player to 8 and the AS version to 2, it wouldn't run right. I am a bit of a newbie to Actionscript (the hardest thing I ever coded was gotoAndPlay (or stop) and fscommand)

      What I want to know is, how can I convert the AS1 code into AS2 code so I can use this $20 effect (!!!!!) in any of my projects compiled for Flash Player 8?
        • 1. Re: Help with converting AS1 to AS2
          If you are using Flash 8, you can set the movie to 8, but why not leave your movie set to AS1? If you aren't coding anything else in AS2, you should be able to keep it at 1.

          One difference between AS1 and AS2 is how you declare variables.

          In AS1 it may look like: var myVar = 0;
          in AS2 it would look like: var myVar:Number = 0; // here your declaring what myVar is
          In AS2 it may also look like var myVar:String = "myString";

          • 2. Re: Help with converting AS1 to AS2
            Mac_Guy Level 1
            I can't set the movie to AS1, I want to add this motion effect to a project I coded in AS2.

            Thanks for the tip on the difference between coding variables.
            • 3. Re: Help with converting AS1 to AS2
              Mac_Guy Level 1
              Here is the AS1 code. So how could I convert it to AS2?

              onClipEvent (load)
              {
              num = 25;
              for (i = 1; num >= i; i++)
              {
              star.duplicateMovieClip("star" + i, i + 1889);
              mc = this["star" + i];
              mc.rX = (random(5) + 4) / 1000;
              mc.rY = (random(5) + 4) / 1000;
              mc._x = random(300) - 150;
              mc._y = random(150) - 75;
              } // end of for
              star._visible = 0;
              }
              onClipEvent (enterFrame)
              {
              for (i = 1; num >= i; i++)
              {
              if (mc._x == 0 || mc._y == 0)
              {
              mc._x = random(100) + 50;
              mc._y = random(50) + 25;
              continue;
              } // end if
              mc = this["star" + i];
              mc.xAcc = mc.xAcc + (10 - mc._x) * mc.rX;
              mc.yAcc = mc.yAcc + (10 - mc._y) * mc.rY;
              mc._x = mc._x + mc.xAcc;
              mc._y = mc._y + mc.yAcc;
              } // end of for
              }