3 Replies Latest reply on Nov 12, 2007 12:04 AM by Newsgroup_User

    convert actionscript 2.0 to 3.0

    Level 7
      Hi,

      I've found the following code to generate snowflakes.
      however it is from actionscript 2.0.

      How can i convert it to actionscript 3.0 ?
      i mean that when i test this under actionscript 3.0, flash cs3 tells me
      for example 1120: Access of undefined property amount.
      and this points to amount = 100.

      thanks a lot.

      ----
      amount = 100;
      mWidth = Stage.width;
      mHeight = Stage.height;
      for (var i = 0; i<amount; i++) {
      thisFlake = this.attachMovie("flake", "flake"+i, i);
      with (thisFlake) {
      _x = Math.random()*mWidth;
      _y = Math.random()*mHeight;
      _xscale = _yscale=_alpha=40+Math.random()*60;
      }
      thisFlake.yspeed = Math.random()*2+.2;
      thisFlake.increment = -0.025+Math.random()*0.05;
      thisFlake.radian = 0; //declare for actionscript 2.0
      thisFlake.onEnterFrame = function() {
      this.radians += this.increment;
      //trace(this.radians);
      this._x += Math.sin(this.radians);
      this._y += this.yspeed;
      if (this._y>=mHeight) {
      this._y = -10;
      this._x = -10+Math.random()*mWidth;
      }
      if (this._x>=mWidth || this._x<=0) {
      this._y = -10;
      this._x = -10+Math.random()*mWidth;
      }
      };
      }
        • 1. Re: convert actionscript 2.0 to 3.0
          kglad Adobe Community Professional & MVP
          you'll need to either

          1. read about as3, because it's significantly different from as2, and learn how to recode this.

          2. beg for someone to do your work for you.

          3. pay someone.

          for 1, read the flash help files and check senocular.com for much helpful information.

          for 2, good luck.

          for 3, send me email via my website at www.kglad.com
          • 2. Re: convert actionscript 2.0 to 3.0
            joeflashTO Level 1
            As kglad inferred, teaching the A-to-Z of AS3 in a forum is quite beyond the scope of discussion. However, the significant changes in AS3 you'll need to learn to convert this code is:
            1. Strongly typing variables is not an option in AS3.
            2. The event model has had a shakeup. Your onEnterFrame is declared quite differently in AS3.
            Check out the excellent Senocular AS3 tutorial for details.
            • 3. Re: convert actionscript 2.0 to 3.0
              Level 7
              This is already what i started to do since yesterday...but as i'm
              currently working on a huge project, i do not have time to read a full
              book and convert this code.

              This flash is a small part of the project, andtill i do not have so much
              time for reading another book... i skip some part of my "education" :-)

              kglad wrote:
              > you'll need to either
              >
              > 1. read about as3, because it's significantly different from as2, and learn
              > how to recode this.
              >
              > 2. beg for someone to do your work for you.
              >
              > 3. pay someone.
              >
              > for 1, read the flash help files and check senocular.com for much helpful
              > information.
              >
              > for 2, good luck.
              >
              > for 3, send me email via my website at www.kglad.com
              >