90 likes | 208 Views
伺服器程式實務期末作業. 老師 : 楊政達 老師 學生 :499k0103_ 張浩琳. 操作. 點擊 CLICK 開始遊戲 在十秒內重複點擊 CLICK 結束後輸入名字並查看排行榜 按右下角 R 可重新開始遊戲. 程式. 影格 1. stop(); b2.addEventListener("click",st); function st(e:MouseEvent) { gotoAndPlay(2); }. 影格 2. var winNum:int=0; var num=0; var lt:int=10;
E N D
伺服器程式實務期末作業 老師:楊政達 老師 學生:499k0103_張浩琳
操作 • 點擊CLICK開始遊戲 • 在十秒內重複點擊CLICK • 結束後輸入名字並查看排行榜 • 按右下角R可重新開始遊戲
程式 • 影格1 • stop(); • b2.addEventListener("click",st); • function st(e:MouseEvent) • { • gotoAndPlay(2); • }
影格2 • var winNum:int=0; • var num=0; • var lt:int=10; • var ltimer:Timer=new Timer(1000,10); • stop(); • b1.addEventListener(MouseEvent.CLICK,clickn); • function clickn(e:MouseEvent) • { • num++; • winNum++; • num_txt.text=String(num); • } • ltimer.start();
ltimer.addEventListener(TimerEvent.TIMER,tt); • function tt(e:TimerEvent) • { • lt=lt-1; • lasttime.text=lt.toString(); • } • ltimer.addEventListener(TimerEvent.TIMER_COMPLETE,endd); • function endd(TimerEvent) • { • gotoAndPlay("end"); • }
影格3 • stop(); • getWin_mc.visible=false; • setWin_mc.visible=true; • gob.visible=true; • var connection:NetConnection; • var chkResponder:Responder; • var getResponder:Responder; • chkResponder = new Responder(onResultchk, onFault); • getResponder = new Responder(onResultget, onFault); • connection = new NetConnection; • var gateway:String = "/amfphp/gateway.php"; • connection.connect(gateway);
function onResultchk(Result:int):void { if(Result==1) { setWin_mc.visible=true; getWin_mc.visible=false; }else{ setWin_mc.visible=false; getWin_mc.visible=true; connection.call("clickgame022.getWin",getResponder); } } function onResultget(Result:Object):void { setWin_mc.visible=false; getWin_mc.visible=true; var i=0; for (i=0;i<Result["totalWin"];i++) { getWin_mc["winName" + i + "_txt"].text=Result["winName" + i]; getWin_mc["winNum" + i + "_txt"].text=Result["winNum" + i]; } }
function onFault(Result:String):void { trace("資料讀取錯誤!!"); } gob.addEventListener("click",yesClick); function yesClick(me:MouseEvent) { connection.call("clickgame022.setWin",null,setWin_mc.winName_txt.text,winNum); connection.call("clickgame022.getWin",getResponder); gob.visible=false; } rego.addEventListener("click",againClick); function againClick(e:MouseEvent) { gotoAndPlay(1); gob.visible=true; } connection.call("clickgame022.chkWin",chkResponder,winNum);
<? • class clickgame022{ • var $userName = "root"; //帳號 • var $password = "111"; //密碼 • var $hostName = "localhost"; //主機(Server) • ?> PHP