home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / CMCD0704.ISO / Software / Demo / elearn / Fizica / interfata.swf / scripts / frame_7 / DoAction.as
Text File  |  2004-05-12  |  2KB  |  79 lines

  1. var mili = 20;
  2. var maxInst = 9;
  3. var min = 180;
  4. var max = 660;
  5. var pas = 20;
  6. var i = 1;
  7. while(i <= maxInst)
  8. {
  9.    this["d" + i].initY = this["d" + i]._y;
  10.    i++;
  11. }
  12. var doTheDew = function(inst, calea)
  13. {
  14.    calea.hideThe.cursor(true);
  15.    txt = new String(inst);
  16.    var excludedInst = Number(txt.slice(1));
  17.    initYexcludedInst = calea["d" + excludedInst]._y;
  18.    gata = true;
  19.    if(calea["d" + excludedInst]._y > min)
  20.    {
  21.       calea["d" + excludedInst]._y += pas * -1;
  22.       gata = false;
  23.    }
  24.    excludedInst++;
  25.    var nextInst = excludedInst;
  26.    initYnextInst = calea["d" + nextInst]._y;
  27.    var j = nextInst;
  28.    while(j <= maxInst)
  29.    {
  30.       if(calea["d" + nextInst]._y < max)
  31.       {
  32.          calea["d" + j]._y += pas * 1;
  33.          gata = false;
  34.       }
  35.       j++;
  36.    }
  37.    if(gata)
  38.    {
  39.       clearInterval(intervalul);
  40.       excludedInst--;
  41.       calea["d" + excludedInst].play();
  42.       calea.hideThe.cursor(false);
  43.    }
  44. };
  45. var undoTheDew = function(inst, calea)
  46. {
  47.    calea.hideThe.cursor(true);
  48.    txt = new String(inst);
  49.    var excludedInst = Number(txt.slice(1));
  50.    initYexcludedInst = calea["d" + excludedInst].initY;
  51.    gata = true;
  52.    if(calea["d" + excludedInst]._y < initYexcludedInst)
  53.    {
  54.       calea["d" + excludedInst]._y += pas * 1;
  55.       gata = false;
  56.    }
  57.    excludedInst++;
  58.    var nextInst = excludedInst;
  59.    initYnextInst = calea["d" + nextInst].initY;
  60.    var j = nextInst;
  61.    while(j <= maxInst)
  62.    {
  63.       if(calea["d" + nextInst]._y > initYnextInst)
  64.       {
  65.          calea["d" + j]._y += pas * -1;
  66.          gata = false;
  67.       }
  68.       j++;
  69.    }
  70.    if(gata)
  71.    {
  72.       clearInterval(intervalul);
  73.       excludedInst--;
  74.       calea["d" + excludedInst].play();
  75.       calea.hideThe.cursor(false);
  76.    }
  77. };
  78. stop();
  79.