我正在 Actionscript 2.0 中进行测验。测验有 8 个问题。每个问题有四个答案,每个答案给出不同的分数。在每一帧上,他们都有两个问题要回答,然后继续下两个问题,依此类推。
我的问题是我需要为每个答案分配最终将被计算的点,并根据点数将用户发送到不同的消息(帧)。
到目前为止,我的代码如下:
// create an array of all nav buttons in group
var groupinfo:Array = [q1a1, q1a2, q1a3, q1a4];
// create a variable to track the currently selected button
var activebtn:MovieClip;
// doRollOver: start the rollover action or process,
// unless the button is currently selected
function doRollOver() {
if (this != activebtn) {
this.gotoAndPlay(2);
}
}
// doRollOut: start the rollout action or process,
// unless the button is currently selected
function doRollOut() {
if (this != activebtn) {
this.gotoAndPlay(1);
}
}
// doClick: 1) return previously selected button to normal, 2) show visual
// indication of selected button, 3) update activebtn
function doClick() {
activebtn.gotoAndPlay(1); // return previously selected to normal
delete this.onEnterFrame; // stop activity on selected mc
activebtn = this; // update pointer to current selection
}
// assign functions to each event for each button in the group
function init() {
for (var mc in groupinfo) {
groupinfo[mc].onRollOver = doRollOver;
groupinfo[mc].onRollOut = doRollOut;
groupinfo[mc].onRelease = doClick;
}
}
init();
此代码负责每一页上答案的活动状态。下一个问题是当跨帧移动时,这些状态不会被记住而是被重置。
///////////////////////// 文件://////////////// //////////
http://www.danielwestrom.se/quiz/quiz.html - 现场演示
将项目文件的 .html 更改为 .zip
谢谢!