Flash AS2测验与每个答案的个别点 [英] Flash AS2 Quiz with individual points for each answer

查看:296
本文介绍了Flash AS2测验与每个答案的个别点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在ActionScript 2.0中进行测验。
测验有8个问题。每个问题有四个答案,每个答案给出不同的观点。在每一帧他们有两个问题要回答,然后移动到下两个等。

我的问题是,我需要分配每个答案点,最终将计算,并根据点数发送用户不同的消息(帧)。



到目前为止,我的代码是如下所示:

$ $ p $ $ $ $ c $>创建一个包含所有导航按钮的数组
var groupinfo:Array = [q1a1,q1a2 ,q1a3,q1a4];

//创建一个变量来跟踪当前选中的按钮
var activebtn:MovieClip;
$ b $ // doRollOver:启动滚动操作或过程,
//除非当前选中按钮
函数doRollOver(){
if(this!= activebtn ){
this.gotoAndPlay(2);


$ b $ // doRollOut:启动转出操作或过程,
//除非当前选中按钮
函数doRollOut(){
if(this!= activebtn){
this.gotoAndPlay(1);


$ b // doClick:1)将先前选择的按钮恢复正常,2)显示可视
//选定按钮的指示,3)更新activebtn
函数doClick(){
activebtn.gotoAndPlay(1); //先前选择正常

删除this.onEnterFrame; //在选定的mc上停止活动

activebtn = this; //更新指向当前选择的指针


//将函数赋给组中每个按钮的每个事件
函数init(){
for(var mc在groupinfo中){
groupinfo [mc] .onRollOver = doRollOver;
groupinfo [mc] .onRollOut = doRollOut;
groupinfo [mc] .onRelease = doClick;
}
}

init();

这段代码负责处理每个页面上答案的活动状态。 接下来的问题是,当移动框架时,这些状态不记得,但重置。

//////////////////文件:////////////////////////////



http://www.danielwestrom。 se / quiz / quiz.html - 现场演示



将.html更改为项目文件的.zip



谢谢!

解决方案

这不是最佳做法,而是使用全局来存储这些结果。例如一个全局数组。

你也可以使用一个类来存储所有的分数,但是因为你有代码,所以我只需要一个全局的。


I'm making a quiz in Actionscript 2.0. The quiz has 8 questions. Each question has four answers and each answer gives different points. On every frame their is two questions to answer and then move on to the next two and so on.

My problem is that I need to assign each answer with points that in the end will be calculated and depending on the number of points send the user to different messages (frames).

My code so far is as follows:

// 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();

This code takes care of the active state for the answers on each page. The next problem is when moving across frames these states aren't remembered but resetted.

///////////////////////////// Files: /////////////////////////////

http://www.danielwestrom.se/quiz/quiz.html - Live demo

Change .html to .zip for project files

Thanks!

解决方案

It's not best-practices, but use a global to store those results. A global array for instance.

You could also use a class to store all of your scores, but as you have the code in the fla, I would just use a global.

这篇关于Flash AS2测验与每个答案的个别点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆