home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / ya-dancer.swf / scripts / frame_3 / DoAction.as
Encoding:
Text File  |  2005-09-29  |  4.5 KB  |  163 lines

  1. stop();
  2. reset = function()
  3. {
  4.    leeWayPerfect = 12;
  5.    leeWayOK = 25;
  6.    scoreHolder.score = 0;
  7.    combo = 0;
  8.    perfects = 0;
  9.    almosts = 0;
  10.    comboHi = 0;
  11.    bps = 1.149;
  12.    pressed = "still";
  13. };
  14. reset();
  15. danceItUp = function()
  16. {
  17.    mainDancerInit = function()
  18.    {
  19.       this.glide = 4 / _root.bps;
  20.       this.moves._alpha = 0;
  21.       this.matchTheMove = function(part)
  22.       {
  23.          var _loc3_ = this.moves[part._name];
  24.          part._x += (_loc3_._x - part._x) / this.glide;
  25.          part._y += (_loc3_._y - part._y) / this.glide;
  26.          part._xscale += (_loc3_._xscale - part._xscale) / this.glide;
  27.          part._yscale += (_loc3_._yscale - part._yscale) / this.glide;
  28.          part._rotation += (_loc3_._rotation - part._rotation) / this.glide;
  29.          part._alpha += (_loc3_._alpha - part._alpha) / this.glide;
  30.       };
  31.       this.bodyParts = [this.hand_l,this.hand_r,this.foot_l,this.foot_r,this.body,this.head,this.shad];
  32.    };
  33.    mainDancerInit.apply(mainDancer);
  34.    mainDancer.onEnterFrame = function()
  35.    {
  36.       for(var _loc3_ in this.bodyParts)
  37.       {
  38.          this.matchTheMove(this.bodyParts[_loc3_]);
  39.       }
  40.       _root.dancin();
  41.    };
  42. };
  43. danceItUp();
  44. dancin = function()
  45. {
  46.    if(Key.isDown(39))
  47.    {
  48.       mainDancer.moves.gotoAndPlay("right");
  49.       _root.pressed = "right";
  50.    }
  51.    if(Key.isDown(37))
  52.    {
  53.       mainDancer.moves.gotoAndPlay("left");
  54.       _root.pressed = "left";
  55.    }
  56.    if(Key.isDown(38))
  57.    {
  58.       mainDancer.moves.gotoAndPlay("up");
  59.       _root.pressed = "up";
  60.    }
  61.    if(Key.isDown(40))
  62.    {
  63.       mainDancer.moves.gotoAndPlay("down");
  64.       _root.pressed = "down";
  65.    }
  66.    if(Key.isDown(38) && Key.isDown(39))
  67.    {
  68.       mainDancer.moves.gotoAndPlay("upRight");
  69.       _root.pressed = "upRight";
  70.    }
  71.    if(Key.isDown(38) && Key.isDown(37))
  72.    {
  73.       mainDancer.moves.gotoAndPlay("upLeft");
  74.       _root.pressed = "upLeft";
  75.    }
  76.    if(Key.isDown(40) && Key.isDown(39))
  77.    {
  78.       mainDancer.moves.gotoAndPlay("downRight");
  79.       _root.pressed = "downRight";
  80.    }
  81.    if(Key.isDown(40) && Key.isDown(37))
  82.    {
  83.       mainDancer.moves.gotoAndPlay("downLeft");
  84.       _root.pressed = "downLeft";
  85.    }
  86.    if(Key.isDown(37) && Key.isDown(39))
  87.    {
  88.       mainDancer.moves.gotoAndPlay("leftRight");
  89.       _root.pressed = "leftRight";
  90.    }
  91.    if(Key.isDown(38) && Key.isDown(40))
  92.    {
  93.       mainDancer.moves.gotoAndPlay("upDown");
  94.       _root.pressed = "upDown";
  95.    }
  96. };
  97. routine_1 = new Array("left","left","left","none","right","right","right","none","up","down","none","none","up","left","right","down","none","upDown","none","none","upLeft","none","upRight","none","upLeft","none","upRight","none","downLeft","downRight","downLeft","downRight","none","leftRight","none","none");
  98. letsDance = function()
  99. {
  100.    stepTemplateInit = function()
  101.    {
  102.       this.bps = _root.bps;
  103.       this.bpb = 3;
  104.       this.count = 1;
  105.       this.startTime = getTimer();
  106.       this.pauseTime = 1000 / bps;
  107.       this.currentRoutine = _root.routine_1;
  108.       this.step.goNow = false;
  109.       this.stepCount = 0;
  110.       _root.score = 0;
  111.       this.goNow = true;
  112.       checkAlpha = function()
  113.       {
  114.          if(this.goNow)
  115.          {
  116.             if(this._alpha > 0)
  117.             {
  118.                this._alpha -= 5;
  119.             }
  120.             else
  121.             {
  122.                this._alpha = 0;
  123.                this.goNow = false;
  124.             }
  125.          }
  126.       };
  127.       var _loc3_ = 1;
  128.       while(_loc3_ < 5)
  129.       {
  130.          this["glow" + _loc3_]._alpha = 0;
  131.          this["glow" + _loc3_].onEnterFrame = checkAlpha;
  132.          _loc3_ = _loc3_ + 1;
  133.       }
  134.    };
  135.    stepTemplateInit.apply(stepTemplate);
  136.    stepTemplate.onEnterFrame = function()
  137.    {
  138.       if(this.goNow)
  139.       {
  140.          this.timeNow = getTimer();
  141.          this.elapsed = this.timeNow - this.startTime;
  142.          if(this.elapsed >= this.pauseTime)
  143.          {
  144.             var _loc3_ = "step" + this.count;
  145.             var _loc2_ = this.attachMovie("step",_loc3_,this.count++);
  146.             _loc2_._y = 100 * this.bpb;
  147.             _loc2_.goNow = true;
  148.             _loc2_._alpha = 5;
  149.             if(this.stepCount >= this.currentRoutine.length)
  150.             {
  151.                this.stepCount = 0;
  152.             }
  153.             this.whatStep = this.currentRoutine[this.stepCount];
  154.             _loc2_.step.gotoAndStop(this.whatStep);
  155.             _loc2_.posi = this.whatStep;
  156.             this.stepCount = this.stepCount + 1;
  157.             this.startTime = getTimer();
  158.          }
  159.       }
  160.    };
  161. };
  162. letsDance();
  163.