home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / scribble.swf / scripts / frame_6 / DoAction.as
Encoding:
Text File  |  2007-02-20  |  5.6 KB  |  240 lines

  1. function levels()
  2. {
  3.    cursor.swapDepths(_root.k++);
  4.    cursor._rotation = (cursor._x - 275) / 6;
  5. }
  6. function drawing()
  7. {
  8.    if(tool == true)
  9.    {
  10.       tap = Math.round(Math.random() * 16777215);
  11.       var _loc1_ = new Color(cursor.crayon.cray);
  12.       _loc1_.setRGB(tap);
  13.       drawingArea.holder.moveTo(prevx,prevy);
  14.       drawingArea.holder.lineStyle(3,tap,70);
  15.       drawingArea.holder.lineTo(cursor._x,cursor._y);
  16.       drawingArea.holder.moveTo(prevx,prevy);
  17.       drawingArea.holder.lineStyle(6,tap,20);
  18.       drawingArea.holder.moveTo(prevx,prevy);
  19.       drawingArea.holder.lineStyle(8,tap,10);
  20.       drawingArea.holder.lineTo(cursor._x + random(6) - 3,cursor._y + random(6) - 3);
  21.    }
  22.    prevx = cursor._x;
  23.    prevy = cursor._y;
  24. }
  25. function clearDrawing()
  26. {
  27.    trace("Drawing Cleared!");
  28.    drawingArea.removeMovieClip();
  29.    attachMovie("drawingArea","drawingArea",_root.k++);
  30. }
  31. function attachLevel()
  32. {
  33.    shell.removeMovieClip();
  34.    if(_root.level > 20)
  35.    {
  36.       _root.nextFrame();
  37.       _root.cstatus = 0;
  38.    }
  39.    else
  40.    {
  41.       attachMovie("cut_" + level,"shell",_root.k++);
  42.       level++;
  43.       levelDisp = "Level " + (level - 1) + " of 20";
  44.       runOnce = true;
  45.       currentStar = 0;
  46.       levCounter = 0;
  47.       levSubSeconds = 0;
  48.       levSeconds = 0;
  49.    }
  50. }
  51. function numbered()
  52. {
  53.    i = 0;
  54.    while(i < totalStars)
  55.    {
  56.       shell[i].num = i + 1;
  57.       i++;
  58.    }
  59. }
  60. function resetStars()
  61. {
  62.    trace("reset stars");
  63.    j = 0;
  64.    while(j <= i)
  65.    {
  66.       shell[j].gotoAndStop(1);
  67.       j++;
  68.    }
  69.    currentStar = 0;
  70.    cleared = true;
  71.    clearDrawing();
  72. }
  73. function hitStar()
  74. {
  75.    i = 0;
  76.    while(i < totalStars)
  77.    {
  78.       if(shell[i].hitTest(cursor.point))
  79.       {
  80.          if(i == currentStar)
  81.          {
  82.             currentStar++;
  83.             shell[i].play();
  84.             currentSound = new Sound(this);
  85.             currentSound.attachSound(i + 1);
  86.             currentSound.start(0,1);
  87.             j = 0;
  88.             while(j < 10)
  89.             {
  90.                b = attachMovie("miniStar","miniStar" + k,k++);
  91.                b._x = shell[i]._x;
  92.                b._y = shell[i]._y;
  93.                b._rotation = random(360);
  94.                b._xscale = random(50);
  95.                b._yscale = b._xscale;
  96.                j++;
  97.             }
  98.             if(i < totalStars - 1)
  99.             {
  100.                b = attachMovie("starOutline","starOutline",k++);
  101.                b._x = shell[i + 1]._x;
  102.                b._y = shell[i + 1]._y;
  103.             }
  104.             if(currentStar == totalStars)
  105.             {
  106.                winLevel();
  107.             }
  108.          }
  109.          else if(shell[i]._currentframe == 1)
  110.          {
  111.             b = attachMovie("starOutline2","starOutline2",k++);
  112.             b._x = shell[currentStar]._x;
  113.             b._y = shell[currentStar]._y;
  114.             resetStars();
  115.             badSound.start(0,1);
  116.             tool = "false";
  117.          }
  118.       }
  119.       i++;
  120.    }
  121. }
  122. function winLevel()
  123. {
  124.    goodSound.start(0,1);
  125.    w = 0;
  126.    while(w < 20)
  127.    {
  128.       a = _root.attachMovie("miniStar","miniStar" + k,k++);
  129.       a._x = shell[currentStar - 1]._x;
  130.       a._y = shell[currentStar - 1]._y;
  131.       a._rotation = random(360);
  132.       a._xscale = random(400);
  133.       a._yscale = a._xscale;
  134.       tap = Math.round(Math.random() * 16777215);
  135.       var _loc2_ = new Color(a);
  136.       _loc2_.setRGB(tap);
  137.       w++;
  138.    }
  139.    tool = "false";
  140.    drawingArea.play();
  141.    f = _root.attachMovie("levelTime","levelTime",k++);
  142.    levelTimeDisp = levSeconds + "." + levSubSeconds + " Seconds!";
  143. }
  144. function timer()
  145. {
  146.    counter++;
  147.    levCounter++;
  148.    subSeconds += 2;
  149.    levSubSeconds += 2;
  150.    if(counter == 50)
  151.    {
  152.       counter = 0;
  153.       subSeconds = 0;
  154.       seconds++;
  155.    }
  156.    if(levCounter == 50)
  157.    {
  158.       levCounter = 0;
  159.       levSubSeconds = 0;
  160.       levSeconds++;
  161.    }
  162.    secondsDisp = seconds + "." + subSeconds;
  163. }
  164. trace("///////////////////////////////////////////////////////////");
  165. trace("//Scribble                                               //");
  166. trace("//By jmtb02, protected by copyright and the CC license   //");
  167. trace("//For more information, visit http://www.jmtb02.com/     //");
  168. trace("//Contact John Cooney, jmtb02@gmail.com                  //");
  169. trace("///////////////////////////////////////////////////////////");
  170. trace(" ");
  171. trace(" ");
  172. cursor.startDrag(true);
  173. Mouse.hide();
  174. _root.cstatus = 1;
  175. badSound = new Sound(this);
  176. badSound.attachSound("badHit");
  177. goodSound = new Sound(this);
  178. goodSound.attachSound("coin");
  179. temp = 0;
  180. totalStars = 9;
  181. runOnce = false;
  182. k = 10;
  183. done = false;
  184. prevx = cursor._x;
  185. prevy = cursor._y;
  186. tool = false;
  187. level = 1;
  188. levelDisp = "Level " + (level - 1) + " of 20";
  189. var counter = 0;
  190. var seconds = 0;
  191. var subSeconds = 0;
  192. var levCounter = 0;
  193. var levSeconds = 0;
  194. var levsubSeconds = 0;
  195. var num = 0;
  196. var finalScore;
  197. attachLevel();
  198. attachMovie("drawingArea","drawingArea",_root.k++);
  199. onEnterFrame = function()
  200. {
  201.    if(_root.cstatus == 1)
  202.    {
  203.       timer();
  204.       drawing();
  205.       levels();
  206.       numbered();
  207.       if(tool == true)
  208.       {
  209.          hitStar();
  210.          cleared = false;
  211.       }
  212.       if(tool == false)
  213.       {
  214.          if(cleared == false)
  215.          {
  216.             cleared = true;
  217.             clearDrawing();
  218.          }
  219.       }
  220.    }
  221. };
  222. onMouseDown = function()
  223. {
  224.    if(cursor.point.hitTest(shell["0"]))
  225.    {
  226.       tool = true;
  227.       trace("tool on--------------------->");
  228.    }
  229. };
  230. onMouseUp = function()
  231. {
  232.    if(currentStar < totalStars && tool == true)
  233.    {
  234.       resetStars();
  235.       tool = false;
  236.    }
  237.    trace("tool off------------------------>");
  238. };
  239. stop();
  240.