今天在闪吧和经典都有朋友问到选择题的制作,所以刚才花时候做了个多顶选择题的简单示例。先看看效果:
代码如下:
//============================================================
//多项选择题回贴示例,经典论坛 终极讨厌 原创,欢迎使用,随便修改
//=============================================================
//
//==========题干==========
ti_txt.text = "我们经典论坛有几个版块? A 2个 B 3个 C 4个 D N个,嘿嘿\n\n\n正确答案是ABC";
//==========答案==========
var daan_str:String = "ABC";
//==========提交==========
tijiao_btn.enabled = false;
tijiao_btn.onRelease = function() {
if (daan_str.length == daan_txt.text.length) {
for (var d:Number = 0; d<daan_str.length; d++) {
//字符串对比
if (daan_txt.text.indexOf(daan_str.charAt(d)) == -1) {
attachMovie("x_mc",x_mc,2008,{_x:256, _y:169});
trace("错了!");
break;
}
}
if (d == daan_str.length) {
attachMovie("g_mc",g_mc,2008,{_x:256, _y:169});
trace("正确!");
}
} else {
trace("错了!");
attachMovie("x_mc",x_mc,2008,{_x:256, _y:169});
}
};
//==========单选按钮初始化==========
var fuwei_array:Array = [A, B, C, D];
function fuwei_func() {
for (var h:Number = fuwei_array.length-1; h>=0; h--) {
fuwei_array[h].selected = false;
fuwei_array[h].addEventListener("click",this);
}
}
this.click = daan_func;
fuwei_func();
//==========显示已选答案==========
function daan_func() {
daan_txt.text = "";
tijiao_btn.enabled = true;
for (var h:Number = 0; h<fuwei_array.length; h++) {
if (fuwei_array[h].selected) {
daan_txt.text += fuwei_array[h]._name;
}
}
}
stop();
源文件下载: 多选题示例-终极讨厌.rar
进入论坛讨论学习:http://space.flash8.net/bbs/thread-339815-1-1.html