home *** CD-ROM | disk | FTP | other *** search
/ Fraggle Rock Season 1 Bonus CD / Fraggle Rock Season 1 Bonus CD.iso / pc / Game / Game.swf / scripts / DefineSprite_636 / frame_1 / DoAction.as
Encoding:
Text File  |  2005-06-24  |  811 b   |  45 lines

  1. function walk()
  2. {
  3.    gotoAndStop("stand");
  4.    play();
  5. }
  6. function beginwalkaction()
  7. {
  8.    this.direction = Math.random() <= 0.5 ? -1 : 1;
  9.    this.onEnterFrame = walkaction;
  10.    gotoAndPlay(this.direction != -1 ? "r" : "l");
  11. }
  12. function walkaction()
  13. {
  14.    if(Math.random() > 0.99)
  15.    {
  16.       this.direction = -1 * this.direction;
  17.       gotoAndPlay(this.direction != -1 ? "r" : "l");
  18.       return undefined;
  19.    }
  20.    if(Math.random() > 0.98)
  21.    {
  22.       this.power();
  23.       return undefined;
  24.    }
  25.    _X = _X + 1 * this.direction;
  26.    wrap();
  27. }
  28. function sit()
  29. {
  30.    this.onEnterFrame = undefined;
  31.    gotoAndStop("sit");
  32.    play();
  33. }
  34. function wrap()
  35. {
  36.    if(direction == 1 && _X > 800)
  37.    {
  38.       _X = -20;
  39.    }
  40.    else if(direction == -1 && _X < -20)
  41.    {
  42.       _X = 800;
  43.    }
  44. }
  45.