var subjectArray:Array=new Array("中國的尼姑最早是何時(shí)出現(xiàn)的","誰是獸中之王","《義勇軍進(jìn)行曲》是哪部電影的主題歌",
"屈原是春秋時(shí)代哪國人","中國第一部彩色故事片是");
var selectArray:Array=new Array("A. 夏朝","B.唐朝","C.南北朝","D.金朝","A.大象","B.老虎","C.獅子","D.動物園園長",
"A.上甘嶺","B.高山下的花環(huán)","C.風(fēng)云兒女","D.英雄兒女","A.齊國","B.楚國","C.燕國","D.趙國","A.霍元甲","B.祝福","C.一雙繡花鞋","D.黃絲帶");
//將所有選擇答案放在一個(gè)數(shù)組里
var answerArray:Array=new Array("C","D","C","B","B");
//將所有答案放在一個(gè)數(shù)組里
var showArray:Array=new Array();
var nameArray:Array=new Array();
var scoreArray:Array=new Array();
var scoreNum:Number=100/subjectArray.length;
var score:int;
var totalScore:int;
var isplay:Boolean;
var field:TextField=new TextField();
var format:TextFormat=new TextFormat("Tahoma");
field.defaultTextFormat=format;
field.text="成績: "+" "+"分";
addChild(field);
field.y=300;
field.x=200;
for (var j:int=0; j<subjectArray.length; j++) {
var subjectText:TextField=new TextField();
subjectText.x=20;
subjectText.y=40*j+20;
subjectText.width=300;
subjectText.mouseEnabled=false;
subjectText.defaultTextFormat=format;
subjectText.text=(j+1)+"."+subjectArray[j]+" ? ";
addChild(subjectText);
var show:Show=new Show();
show.y=40+j*40;
show.x=20;
show.showText.mouseEnabled=false;
show.indexText.text=(j+1)+".";
show.indexText.mouseEnabled=false;
show.judgeText.mouseEnabled=false;
showArray.push(show);
addChild(show);
}
for (var i:uint=0; i<selectArray.length; i++) {
var selectButton:Button=new Button();
addChild(selectButton);
selectButton.x = 100+i%4*110;
selectButton.y = 40+Math.floor(i/4)*40;
//排列
selectButton.buttonText.text=selectArray[i];
selectButton.name=i.toString();
nameArray.push(selectArray[i].charAt(0));
//將數(shù)組里各索引第一個(gè)字符裝進(jìn)數(shù)組
selectButton.addEventListener(MouseEvent.CLICK,selectButtonClick);
}
function selectButtonClick(event:MouseEvent) {
var id:int=int(event.target.name);
if (!isplay) {
//-----------------------------------------------------------
if (id<4) {
showArray[0].showText.text=nameArray[id];
}
if (id>=4 && id<8) {
showArray[1].showText.text=nameArray[id];
}
if (id>=8 && id<12) {
showArray[2].showText.text=nameArray[id];
}
if (id>=12 && id<16) {
showArray[3].showText.text=nameArray[id];
}
if (id>=16 && id<20) {
showArray[4].showText.text=nameArray[id];
}
//左邊括號里顯示的選項(xiàng),這里有缺點(diǎn)
//--------------------------------------------------------------
}
}
var button:Button=new Button();
addChild(button);
button.x=300;
button.y=300;
button.buttonText.text="提交";
button.addEventListener(MouseEvent.CLICK,buttonClick);
function buttonClick(event:MouseEvent) {
isplay=!isplay;
if (isplay) {
button.buttonText.text="清除";
for (var ii:uint=0; ii<subjectArray.length; ii++) {
scoreArray.push(score);
if (showArray[ii].showText.text==answerArray[ii]) {
showArray[ii].judgeText.text="√";
scoreArray[ii]=scoreNum;
} else {
showArray[ii].judgeText.text="×";
scoreArray[ii]=0;
}
totalScore+=scoreArray[ii];
}
field.text="成績: "+totalScore.toString()+" 分";
} else {
totalScore=0;
button.buttonText.text="提交";
field.text="成績: "+" "+"分";
for (var jj:uint=0; jj<subjectArray.length; jj++) {
showArray[jj].showText.text="";
showArray[jj].judgeText.text="";
}
}
}
源文件附件下載:
選擇填空題.rar本文章由
南寧網(wǎng)站建設(shè)、
南寧網(wǎng)站優(yōu)化、
南寧網(wǎng)絡(luò)公司整理,轉(zhuǎn)載請注明出處:http://m.lidajijin.com/