AS3测验及答案 [英] AS3 quiz and answers

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

问题描述

下面是我的问题;

我要交了白卷,在年底示人,他/她有气质的艇员选拔特定的大学课程。该测验将提出10个问题,每个有2个答案,在点击一个答案,积分将获得的具体课程。

I want to make a quiz that at the end shows a person the qualities he/she has for chosing a specific college course. The quiz will ask 10 questions which each have 2 answers, upon clicking an answer, points will be earned for a specific course.

例如这个问题可能是你想工作时使用电脑,或与人?

For example the question could be 'Do you want to work with computers, or with people?'

回答后点的计算机在课程的Informatica,设计和编辑将获得 当回答人们点将在医生的课程来获得,社工等(我只是命名的东西这里有个例子)

Upon answering Computers points will be gained at the courses Informatica, Designing and Editing Upon answering People points will be gained at the courses Doctor, Social Worker etc (Im just naming things here for example)

我希望人们去通过测验,回答问题,并看看到底多少,他们赚了点,每门课程,看哪些课程是最适合他们的潜力。

I want people to go through the quiz, answer the questions, and see in the end how much points they earned for each course, seeing which courses are best suited for their potential.

现在的code可能是简单的。我的Flash CS5和使用ActionScript 3,在一个层面上我的第一帧我的第一个问题和两个按钮,并有这样的code:

Now the code could be simple. I have Flash CS5 and use Actionscript 3. On my first frame of Layer one I have the first question and two buttons and have this code:

stop();
btn1.addEventListener(MouseEvent.CLICK, release1);
btn2.addEventListener(MouseEvent.CLICK, release2);
var option1:Number = 0;
var option2:Number = 0;

function release1(){
    option1 += 1;
    gotoAndStop(2);
}

function release2(){
    option2 += 1;
    gotoAndStop(2);
}

和第二帧上我有一个正常的短信说像'的结果是:然后两(暂时)中,我希望有结果的动态文本框

and on the second frame I have a normal text saying something like 'the results are:' and then two (for the time being) dynamic text boxes in which I want to have the results.

这里的问题,我不知道如何来显示结果。我曾以此为code:

Here's the problem, I don't know how to show the results. I have this as code:

txt1.text = option1;
txt2.text = option2;

但我得到的错误 1067:Number类型的值隐式强制给无关联的字符串类型

...不幸的是林还挺新CS5和ActionScript 3,所以我不知道该怎么办。当我尝试我的脚本了,它只是起到它像一个影片剪辑。

...unfortunatly Im kinda new to CS5 and Actionscript 3 so I don't know what to do. When I try my script out it just plays it like a movieclip.

谁能告诉我wheter Im做一个小东西错了还是我完全在错误的过程中这样做呢?

Can someone tell me wheter Im doing a small thing wrong or am I entirely on the wrong course in doing this?

推荐答案

这是因为错误的描述说,你要什么类型的字符串分配到的东西键入。你必须设置文本框显示的分数,但 txt1.text 将只接受字符串。您可以使用的toString()投的数量,使您的文本字段会接受它:

It's as the error description says, you're trying to assign something of type String to something of type Number. You've got the right idea of setting the text box to display the scores but txt1.text will only accept a String. You can use toString() to cast the number so that your text field will accept it:

txt1.text = option1.toString();

此外,要停止该项目打像一个影片剪辑添加命令停止(); 的每一帧,你想申请到等待(你已把将其添加到所述第一框架上,从而只需将其添加到第二个)。

Also, to stop the project playing like a movie clip add the command stop(); on each frame you would like the application to wait at (you've already added it to the first frame so just add it to the second).

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

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