Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //AS3 basic
- import flash.display.MovieClip;
- gotoAndStop(1, "core");
- var autom:autombol = new autombol(),
- posisi:int,
- kerview:Boolean=false,
- resview:Boolean=false,
- potup:Boolean=false,
- mcker:kerabat = new kerabat(),
- mcres:mcrespon = new mcrespon(),
- myTextFormat:TextFormat = new TextFormat();
- myTextFormat.size = 24;
- mcker.x = 240;
- mcker.y = 400;
- mcres.x = 240;
- mcres.y = 400;
- //AS view
- function viewinfo()
- {
- if (resview)
- {
- offresume();
- }
- addChild(mcker);
- if (! (posisi == 0))
- {
- tbmenu.visible = true;
- setChildIndex(tbmenu,(this.numChildren - 1));
- }
- tbmetu.visible = true;
- setChildIndex(tbmetu,(this.numChildren - 1));
- kerview = true;
- }
- function offinfo()
- {
- if (! (posisi == 0))
- {
- tbmenu.visible = false;
- }
- tbmetu.visible = false;
- removeChild(mcker);
- kerview = false;
- }
- function viewresume()
- {
- addChild(mcres);
- tbmenu.visible = true;
- setChildIndex(tbmenu,(numChildren - 1));
- tbulang.visible = true;
- setChildIndex(tbulang,(numChildren - 1));
- resview = true;
- }
- function offresume()
- {
- tbmenu.visible = false;
- tbulang.visible = false;
- removeChild(mcres);
- resview = false;
- }
- function offobject()
- {
- for (var b:int=1; b<=jumobj; b++)
- {
- removeChild(this["obj" + b]);
- }
- }
- //AS button
- function cmenu(event:MouseEvent):void
- {
- autom.play();
- myTimer.stop();
- if (kerview)
- {
- offinfo();
- }
- if (resview)
- {
- offresume();
- }
- if (posisi==2)
- {
- offobject();
- }
- gotoAndStop(1);
- }
- function cmetu(event:MouseEvent):void
- {
- autom.play();
- myTimer.stop();
- gotoAndPlay(1, "closing");
- offinfo();
- if (! (posisi == 0))
- {
- offobject();
- }
- }
- function ckerabat(event:MouseEvent):void
- {
- autom.play();
- if (kerview)
- {
- offinfo();
- }
- else
- {
- viewinfo();
- }
- }
- function culang(event:MouseEvent):void
- {
- autom.play();
- benar = 0;
- offresume();
- myTimer.reset();
- timer_txt.text = "00:00";
- myTimer.start();
- for (var i:int=1; i<=jumobj; i++)
- {
- this["obj" + i].x = 80+(Math.random()*320);
- this["obj" + i].y = 80+(Math.random()*640);
- this["obj" + i].picbelum = true;
- }
- }
- //AS for jigsaw
- var benar,jumobj,picno:int;
- var yes:suryayes = new suryayes(),
- aduh:suryaaduh = new suryaaduh(),
- asik:selesai = new selesai();
- function panjangmenu(jumpic:int)
- {
- //AS Navigation
- Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
- var awaly,akhiry:int = 0;
- posisi = 0;
- tbmetu.addEventListener(MouseEvent.MOUSE_UP,cmetu);
- tbmenu.addEventListener(MouseEvent.MOUSE_UP,cmenu);
- tbkerabat.addEventListener(MouseEvent.MOUSE_UP,ckerabat);
- tbulang.addEventListener(MouseEvent.MOUSE_UP,culang);
- tbmetu.visible = false;
- tbmenu.visible = false;
- tbulang.visible = false;
- for (var i:int=1; i<=jumpic; i++)
- {
- tbmacampic(i);
- }
- //AS slide
- function onTouchBegin(event:TouchEvent)
- {
- awaly = event.stageY;
- pg.ig.addEventListener(TouchEvent.TOUCH_MOVE, onTouchMove);
- pg.ig.addEventListener(TouchEvent.TOUCH_END, onTouchEnd);
- }
- function onTouchMove(event:TouchEvent)
- {
- if ((pg.ig.y <= 0)&&(pg.ig.y >= (470-pg.ig.height)))
- {
- pg.ig.y = event.stageY - awaly + akhiry;
- }
- }
- function onTouchEnd(event:TouchEvent)
- {
- if (pg.ig.y > 0)
- {
- pg.ig.y = 0;
- }
- if (pg.ig.y < (470 - pg.ig.height))
- {
- pg.ig.y = (470 - pg.ig.height);
- }
- akhiry = pg.ig.y;
- }
- pg.ig.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);
- }
- var siye:int;
- function cdown(event:MouseEvent):void
- {
- siye = mouseY;
- }
- function tbmacampic(no:int)
- {
- function picdg(event:MouseEvent):void
- {
- if (Math.abs(mouseY-siye)<20)
- {
- autom.play();
- nextFrame();
- picno = no;
- }
- }
- pg.ig.getChildByName(("tbpic" + no)).gotoAndStop(no);
- pg.ig.getChildByName(("tbpic" + no)).addEventListener(MouseEvent.MOUSE_DOWN,cdown);
- pg.ig.getChildByName(("tbpic" + no)).addEventListener(MouseEvent.MOUSE_UP,picdg);
- }
- function panjanglevel(jumlev:int)
- {
- posisi = 1;
- benar = 0;
- for (var a:int=1; a<=jumlev; a++)
- {
- tblevel(a);
- }
- }
- function tblevel(no:int)
- {
- this["tblevel" + no].setStyle("textFormat", myTextFormat);
- function clevel(event:MouseEvent):void
- {
- autom.play();
- gotoAndStop(no+2);
- }
- this["tblevel" + no].addEventListener(MouseEvent.MOUSE_UP,clevel);
- }
- var batas1,batas2:int;
- function allpieces(sijumpic:int,bat1:int,bat2:int):void
- {
- batas1 = bat1;
- batas2 = bat2;
- posisi = 2;
- jumobj = sijumpic;
- for (var i:int=1; i<=jumobj; i++)
- {
- this["obj" + i].x = 80+(Math.random()*320);
- this["obj" + i].y = 80+(Math.random()*640);
- this["target" + i].alpha = 0;
- this["obj" + i].mcgambar.gotoAndStop(picno);
- setChildIndex(getChildByName("obj" + i),(numChildren - 1));
- jodoh("obj"+i, "target"+i);
- }
- //AS timer;
- myTimer.addEventListener(TimerEvent.TIMER, timerHandler);
- myTimer.reset();
- timer_txt.text = "00:00";
- myTimer.start();
- }
- function mdown(event:MouseEvent):void
- {
- if (event.currentTarget.picbelum)
- {
- setChildIndex(this[event.currentTarget.name],(this.numChildren - 1));
- event.currentTarget.startDrag();
- event.currentTarget.x = mouseX;
- event.currentTarget.y = mouseY;
- }
- }
- function jodoh(objnya:String, targetnya:String):void
- {
- this[objnya].addEventListener(MouseEvent.MOUSE_DOWN, mdown);
- this[objnya].addEventListener(MouseEvent.MOUSE_UP, mup);
- function mup(event:MouseEvent):void
- {
- if (event.currentTarget.picbelum)
- {
- event.currentTarget.stopDrag();
- if (event.currentTarget.dites.hitTestObject(getChildByName(targetnya)))
- {
- //clik and drug right place
- benar += 1;
- event.currentTarget.x = getChildByName(targetnya).x;
- event.currentTarget.y = getChildByName(targetnya).y;
- if (benar==jumobj)
- {
- asik.play();
- viewresume();
- myTimer.stop();
- if (min==0)
- {
- if (sec<=batas1)
- {
- mcres.gotoAndPlay(31);
- }
- else if (sec<=batas2)
- {
- mcres.gotoAndPlay(16);
- }
- else
- {
- mcres.gotoAndPlay(2);
- }
- }
- }
- else
- {
- event.currentTarget.picbelum = false;
- yes.play();
- }
- }
- else
- {
- //clik and drug wrong place
- aduh.play();
- }
- }
- }
- }
- //AS timer
- var sec,min,hr:uint = 0,
- timernya:String,
- myTimer:Timer = new Timer(1000);
- function timerHandler(e:TimerEvent):void
- {
- sec = uint(myTimer.currentCount % 60);
- min = uint((myTimer.currentCount/60)%60);
- //hr = uint((myTimer.currentCount/60)/60);
- timernya = ((uint(min) < 10) ? "0" + min:min) + ":" + ((uint(sec) < 10) ? "0" + sec:sec);
- timer_txt.text = timernya;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement