作者cjcjovup (啊嚓!)
看板Flash
标题Re: [问题] 选择题随机出几题
时间Fri Aug 21 05:46:10 2009
1F:推 stopcrying:试着在第一格加上变数用来纪录已经答对几格,并在换问08/20 12:08
2F:→ stopcrying:题时检查答对题数以决定要不要跳到结束画面这样?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)