语录提交--登陆--注册--论坛交流--站长博客

Flash编程无基础入门教程

[作者:来自网络][日期:2007-12-27][导航:Flash教程 >> ActionScript2 >> Flash编程无基础入门教程]
   // 然后问题输入MC的qText文本框中
questionClip.qText = questionsArray[currentQuestion].questionText;
// Create the individual answer clips in the question clip
// 以下循环将结合选项模版生成这一条题目的各个选项的MC
// questionsArray[currentQuestion].answers记得吗?选项这个属性可是个数组,所以我们把它的长度作为循环的次数,这个数组有多大,我们就生成多少个选项
for (var j = 0; j < questionsArray[currentQuestion].answers.length; j++) {
// Attach our linked answerTemplate clip from the Library.
// It contains a generalized button and a text field for the question.
// 用answerTemplate做模版生成MC,MC名为"answer" + j ,即第一个选项MC名为answer0,第二个为answer1,选项的名字可是关系到按钮选什么的,如果你忘了,看看上面有 @@ 标记的地方
// 同时它们的深度为j,每次不同
// 但和上面不同的是,我们要把选项MC生成到题目MC里,这样我们清除题目MC的同时也清除了选项
// 所以写成questionClip.attachMovie
questionClip.attachMovie("answerTemplate", "answer" + j, j);
// Place this answer clip in line below the question.
// 设定MC的位置,第一个高度为70,之后顺序加15
questionClip["answer" + j]._y += 70 + (j * 15);
questionClip["answer" + j]._x -= 100;
// Set the text field in the answer clip to the appropriate
// element of this question's answer array.
// 下面语句的:questionClip["answer" + j]可不是指数组,j=0的时候,它代表questionClip.answer0,具体解释可见上一章。
// 这句语句的作用是把questionsArray[currentQuestion]这个对象数组里面的answers[j]数组,输入到对应的选项MC的answerText文本框中,就是该选项的内容
questionClip["answer" + j].answerText = questionsArray[currentQuestion].answers[j];
}
//生成选项的循环结束
}
// Function to register the user's answers
// 以下是记录答题者答案的函数,记录在数组userAnswers中,和上一例同
// 每一个选项如果被选都会调用此函数,并用参数choice传来作答的答案
function answer (choice) {
userAnswers.push(choice);
// 判断是否题目全部完成,是的话清楚掉题目MC,并跳转到quizEnd帧
if (currentQuestion + 1 == questionsArray.length) {
questionClip.removeMovieClip();
gotoAndStop ("quizEnd");
} else {
// 在这里改变题目的编号,然后调用makeQuestion函数再次生成新的题目
currentQuestion++;
makeQuestion(currentQuestion);

[文章热度:]


123456789101112131415161718192021

上一页:Flash 物理效果收藏

下一页:Flash As编码习惯

最新话题

网站导航

搜索

网站公告


Copyright 2007 51as.com. Some Rights Reserved.
鄂ICP备07003189号

Powered by: KingCMS 5.0.1.0217