Advertisement
Guest User

kirim khudori

a guest
Jul 31st, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.50 KB | None | 0 0
  1. //AS3 basic
  2. import flash.display.MovieClip;
  3. gotoAndStop(1, "core");
  4.  
  5. var autom:autombol = new autombol(),
  6. posisi:int,
  7. kerview:Boolean=false,
  8. resview:Boolean=false,
  9. potup:Boolean=false,
  10. mcker:kerabat = new kerabat(),
  11. mcres:mcrespon = new mcrespon(),
  12. myTextFormat:TextFormat = new TextFormat();
  13. myTextFormat.size = 24;
  14.  
  15. mcker.x = 240;
  16. mcker.y = 400;
  17. mcres.x = 240;
  18. mcres.y = 400;
  19.  
  20. //AS view
  21. function viewinfo()
  22. {
  23.     if (resview)
  24.     {
  25.         offresume();
  26.     }
  27.     addChild(mcker);
  28.     if (! (posisi == 0))
  29.     {
  30.         tbmenu.visible = true;
  31.         setChildIndex(tbmenu,(this.numChildren - 1));
  32.     }
  33.     tbmetu.visible = true;
  34.     setChildIndex(tbmetu,(this.numChildren - 1));
  35.     kerview = true;
  36. }
  37. function offinfo()
  38. {
  39.     if (! (posisi == 0))
  40.     {
  41.         tbmenu.visible = false;
  42.     }
  43.     tbmetu.visible = false;
  44.     removeChild(mcker);
  45.     kerview = false;
  46. }
  47. function viewresume()
  48. {
  49.     addChild(mcres);
  50.     tbmenu.visible = true;
  51.     setChildIndex(tbmenu,(numChildren - 1));
  52.     tbulang.visible = true;
  53.     setChildIndex(tbulang,(numChildren - 1));
  54.     resview = true;
  55. }
  56. function offresume()
  57. {
  58.     tbmenu.visible = false;
  59.     tbulang.visible = false;
  60.     removeChild(mcres);
  61.     resview = false;
  62. }
  63. function offobject()
  64. {
  65.     for (var b:int=1; b<=jumobj; b++)
  66.     {
  67.         removeChild(this["obj" + b]);
  68.     }
  69. }
  70.  
  71. //AS button
  72. function cmenu(event:MouseEvent):void
  73. {
  74.     autom.play();
  75.     myTimer.stop();
  76.     if (kerview)
  77.     {
  78.         offinfo();
  79.     }
  80.     if (resview)
  81.     {
  82.         offresume();
  83.     }
  84.     if (posisi==2)
  85.     {
  86.         offobject();
  87.     }
  88.     gotoAndStop(1);
  89. }
  90. function cmetu(event:MouseEvent):void
  91. {
  92.     autom.play();
  93.     myTimer.stop();
  94.     gotoAndPlay(1, "closing");
  95.     offinfo();
  96.     if (! (posisi == 0))
  97.     {
  98.         offobject();
  99.     }
  100. }
  101. function ckerabat(event:MouseEvent):void
  102. {
  103.     autom.play();
  104.     if (kerview)
  105.     {
  106.         offinfo();
  107.     }
  108.     else
  109.     {
  110.         viewinfo();
  111.     }
  112. }
  113. function culang(event:MouseEvent):void
  114. {
  115.     autom.play();
  116.     benar = 0;
  117.     offresume();
  118.     myTimer.reset();
  119.     timer_txt.text = "00:00";
  120.     myTimer.start();
  121.     for (var i:int=1; i<=jumobj; i++)
  122.     {
  123.         this["obj" + i].x = 80+(Math.random()*320);
  124.         this["obj" + i].y = 80+(Math.random()*640);
  125.         this["obj" + i].picbelum = true;
  126.     }
  127. }
  128.  
  129. //AS for jigsaw
  130. var benar,jumobj,picno:int;
  131. var yes:suryayes = new suryayes(),
  132.     aduh:suryaaduh = new suryaaduh(),
  133.     asik:selesai = new selesai();
  134.  
  135. function panjangmenu(jumpic:int)
  136. {
  137.     //AS Navigation
  138.     Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
  139.     var awaly,akhiry:int = 0;
  140.     posisi = 0;
  141.     tbmetu.addEventListener(MouseEvent.MOUSE_UP,cmetu);
  142.     tbmenu.addEventListener(MouseEvent.MOUSE_UP,cmenu);
  143.     tbkerabat.addEventListener(MouseEvent.MOUSE_UP,ckerabat);
  144.     tbulang.addEventListener(MouseEvent.MOUSE_UP,culang);
  145.     tbmetu.visible = false;
  146.     tbmenu.visible = false;
  147.     tbulang.visible = false;
  148.     for (var i:int=1; i<=jumpic; i++)
  149.     {
  150.         tbmacampic(i);
  151.     }
  152.  
  153.     //AS slide
  154.     function onTouchBegin(event:TouchEvent)
  155.     {
  156.         awaly = event.stageY;
  157.         pg.ig.addEventListener(TouchEvent.TOUCH_MOVE, onTouchMove);
  158.         pg.ig.addEventListener(TouchEvent.TOUCH_END, onTouchEnd);
  159.     }
  160.     function onTouchMove(event:TouchEvent)
  161.     {
  162.         if ((pg.ig.y <= 0)&&(pg.ig.y >= (470-pg.ig.height)))
  163.         {
  164.             pg.ig.y = event.stageY - awaly + akhiry;
  165.         }
  166.     }
  167.     function onTouchEnd(event:TouchEvent)
  168.     {
  169.         if (pg.ig.y > 0)
  170.         {
  171.             pg.ig.y = 0;
  172.         }
  173.         if (pg.ig.y < (470 - pg.ig.height))
  174.         {
  175.             pg.ig.y = (470 - pg.ig.height);
  176.         }
  177.         akhiry = pg.ig.y;
  178.     }
  179.     pg.ig.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);
  180. }
  181.  
  182. var siye:int;
  183. function cdown(event:MouseEvent):void
  184. {
  185.     siye = mouseY;
  186. }
  187. function tbmacampic(no:int)
  188. {
  189.     function picdg(event:MouseEvent):void
  190.     {
  191.         if (Math.abs(mouseY-siye)<20)
  192.         {
  193.             autom.play();
  194.             nextFrame();
  195.             picno = no;
  196.         }
  197.     }
  198.     pg.ig.getChildByName(("tbpic" + no)).gotoAndStop(no);
  199.     pg.ig.getChildByName(("tbpic" + no)).addEventListener(MouseEvent.MOUSE_DOWN,cdown);
  200.     pg.ig.getChildByName(("tbpic" + no)).addEventListener(MouseEvent.MOUSE_UP,picdg);
  201. }
  202. function panjanglevel(jumlev:int)
  203. {
  204.     posisi = 1;
  205.     benar = 0;
  206.     for (var a:int=1; a<=jumlev; a++)
  207.     {
  208.         tblevel(a);
  209.     }
  210. }
  211. function tblevel(no:int)
  212. {
  213.     this["tblevel" + no].setStyle("textFormat", myTextFormat);
  214.     function clevel(event:MouseEvent):void
  215.     {
  216.         autom.play();
  217.         gotoAndStop(no+2);
  218.     }
  219.     this["tblevel" + no].addEventListener(MouseEvent.MOUSE_UP,clevel);
  220. }
  221.  
  222. var batas1,batas2:int;
  223. function allpieces(sijumpic:int,bat1:int,bat2:int):void
  224. {
  225.     batas1 = bat1;
  226.     batas2 = bat2;
  227.     posisi = 2;
  228.     jumobj = sijumpic;
  229.     for (var i:int=1; i<=jumobj; i++)
  230.     {
  231.         this["obj" + i].x = 80+(Math.random()*320);
  232.         this["obj" + i].y = 80+(Math.random()*640);
  233.         this["target" + i].alpha = 0;
  234.         this["obj" + i].mcgambar.gotoAndStop(picno);
  235.         setChildIndex(getChildByName("obj" + i),(numChildren - 1));
  236.         jodoh("obj"+i, "target"+i);
  237.     }
  238.     //AS timer;
  239.     myTimer.addEventListener(TimerEvent.TIMER, timerHandler);
  240.     myTimer.reset();
  241.     timer_txt.text = "00:00";
  242.     myTimer.start();
  243. }
  244.  
  245. function mdown(event:MouseEvent):void
  246. {
  247.     if (event.currentTarget.picbelum)
  248.     {
  249.         setChildIndex(this[event.currentTarget.name],(this.numChildren - 1));
  250.         event.currentTarget.startDrag();
  251.         event.currentTarget.x = mouseX;
  252.         event.currentTarget.y = mouseY;
  253.     }
  254. }
  255.  
  256. function jodoh(objnya:String, targetnya:String):void
  257. {
  258.     this[objnya].addEventListener(MouseEvent.MOUSE_DOWN, mdown);
  259.     this[objnya].addEventListener(MouseEvent.MOUSE_UP, mup);
  260.     function mup(event:MouseEvent):void
  261.     {
  262.         if (event.currentTarget.picbelum)
  263.         {
  264.             event.currentTarget.stopDrag();
  265.             if (event.currentTarget.dites.hitTestObject(getChildByName(targetnya)))
  266.             {
  267.                 //clik and drug right place
  268.                 benar +=  1;
  269.                 event.currentTarget.x = getChildByName(targetnya).x;
  270.                 event.currentTarget.y = getChildByName(targetnya).y;
  271.                 if (benar==jumobj)
  272.                 {
  273.                     asik.play();
  274.                     viewresume();
  275.                     myTimer.stop();
  276.                     if (min==0)
  277.                     {
  278.                         if (sec<=batas1)
  279.                         {
  280.                             mcres.gotoAndPlay(31);
  281.                         }
  282.                         else if (sec<=batas2)
  283.                         {
  284.                             mcres.gotoAndPlay(16);
  285.                         }
  286.                         else
  287.                         {
  288.                             mcres.gotoAndPlay(2);
  289.                         }
  290.                     }
  291.                 }
  292.                 else
  293.                 {
  294.                     event.currentTarget.picbelum = false;
  295.                     yes.play();
  296.                 }
  297.             }
  298.             else
  299.             {
  300.                 //clik and drug wrong place
  301.                 aduh.play();
  302.             }
  303.         }
  304.     }
  305. }
  306.  
  307. //AS timer
  308. var sec,min,hr:uint = 0,
  309. timernya:String,
  310. myTimer:Timer = new Timer(1000);
  311.  
  312. function timerHandler(e:TimerEvent):void
  313. {
  314.     sec = uint(myTimer.currentCount % 60);
  315.     min = uint((myTimer.currentCount/60)%60);
  316.     //hr = uint((myTimer.currentCount/60)/60);
  317.     timernya = ((uint(min) < 10) ? "0" + min:min) + ":" + ((uint(sec) < 10) ? "0" + sec:sec);
  318.     timer_txt.text = timernya;
  319. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement