10 Replies Latest reply on Nov 27, 2009 8:29 AM by kglad

    Strange AVM AS2!! Whats the difference!?

    kornesh Level 1

      //this code produces syntax error
      onClipEvent (load) {
           speed = 5;
           radius = 9;
      }
      onClipEvent (enterFrame) {
          if (Key.isDown(Key.RIGHT)) {
              this._x += speed;
          }
          if (Key.isDown(Key.LEFT)) {
              this._x -= speed;
          }
          if (Key.isDown(Key.UP)) {
              this._y -= speed;
          }
         if (Key.isDown(Key.DOWN)) {
              this._y += speed;
          }
          while (_root.walls.hitTest(this._x, this._y+radius, true)) {
              this._y--;
          }
          while (_root.walls.hitTest(this._x, this._y-radius, true)) {
              this._y++;
          }
          while (_root.walls.hitTest(this._x+radius, this._y, true)) {
              this._x--;
          }
          while (_root.walls.hitTest(this._x-radius, this._y, true)) {
              this._x++;
          }
      }
      
      
      //while this doesnt
      
      onClipEvent (load) {
         speed = 5;
         radius = 9;
      }
      onClipEvent (enterFrame) {
         if (Key.isDown(Key.RIGHT)) {
             this._x += speed;
         }
         if (Key.isDown(Key.LEFT)) {
             this._x -= speed;
         }
         if (Key.isDown(Key.UP)) {
             this._y -= speed;
         }
         if (Key.isDown(Key.DOWN)) {
             this._y += speed;
         }
         while (_root.walls.hitTest(this._x, this._y+radius, true)) {
             this._y--;
         }
         while (_root.walls.hitTest(this._x, this._y-radius, true)) {
             this._y++;
         }
         while (_root.walls.hitTest(this._x+radius, this._y, true)) {
             this._x--;
         }
         while (_root.walls.hitTest(this._x-radius, this._y, true)) {
             this._x++;
         }
      }
      
       
      

       

       

      strange avm.jpg