Re: [問題] 選擇題隨機出幾題

看板Flash作者 (啊嚓!)時間16年前 (2009/08/21 05:46), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)

08/20 12:08,
試著在第一格加上變數用來紀錄已經答對幾格,並在換問
08/20 12:08

08/20 12:09,
題時檢查答對題數以決定要不要跳到結束畫面這樣?
08/20 12:09
感謝這位高手提醒!! 我試出來了^口^ http://140.130.43.178/~tschung97eid/G4/s0963373~2/selectNEW.swf ※15題隨機出5題 (紅底部分是修改的地方.沒改很多~) 第一格程式碼:(裡面的Q1~QEnd是第二格到最後一格的影格名稱) stop(); stopAllSounds(); var totalQ:Number = 15; var choiceQ:Number = 15; var nextQ:Number = 0; var totalscore:Number = 0; var selQ:Array =["Q1","Q2","Q3","Q4","Q5","Q6","Q7","Q8","Q9","Q10","Q11", "Q12","Q13","Q14","Q15","QEnd"]; for(i = 0; i < totalQ; i++) { j = Math.floor(Math.random() * totalQ); temp = selQ[i]; selQ[i] = selQ[j]; selQ[j] = temp; } selQ[choiceQ] = selQ[totalQ]; start_btn.onPress = function() { gotoAndPlay(selQ[nextQ++]); } 第二格程式碼:(之後的三~十六格都差不多) stop(); stopAllSounds(); var rightSound:Sound = new Sound(); rightSound.attachSound("1"); var wrongSound:Sound = new Sound(); wrongSound.attachSound("bibi"); var clickedTimes = 0; a1.enabled = true; a2.enabled = true; a3.enabled = true; next_btn._visible = false; selIcon_mc._visible = false; var sortA:Array = ["a1", "a2", "a3"]; for(j = 0; j < 3; j++) { k = Math.floor(Math.random() * 3); temp = sortA[j]; sortA[j] = sortA[k]; sortA[k] = temp; } this[sortA[0]]._x = 50; this[sortA[0]]._y = 200; this[sortA[1]]._x = 50; this[sortA[1]]._y = 275; this[sortA[2]]._x = 50; this[sortA[2]]._y = 350; a1.onPress = function() { selIcon_mc._visible = true; selIcon_mc._x = 25; selIcon_mc._y = this._y; feedback_lbl.text = "O"; stopAllSounds(); rightSound.start(); next_btn._visible = true; totalscore+=20; a1.enabled = false; a2.enabled = false; a3.enabled = false; } a2.onPress = function() { selIcon_mc._visible = true; selIcon_mc._x = 25; selIcon_mc._y = this._y; feedback_lbl.text = "X"; stopAllSounds(); wrongSound.start(); } a3.onPress = function() { selIcon_mc._visible = true; selIcon_mc._x = 25; selIcon_mc._y = this._y; feedback_lbl.text = "X"; stopAllSounds(); wrongSound.start(); } Qnum_lbl.text = nextQ.toString() + "."; next_btn.onPress = function() { if(totalscore==100){ gotoAndStop(17); }else{ gotoAndPlay(selQ[nextQ++]); } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.127.140.238 ※ 編輯: cjcjovup 來自: 59.127.140.238 (08/21 05:47) ※ 編輯: cjcjovup 來自: 59.127.140.238 (08/21 05:48) ※ 編輯: cjcjovup 來自: 59.127.140.238 (08/21 05:50)
文章代碼(AID): #1AZSGZwF (Flash)
文章代碼(AID): #1AZSGZwF (Flash)