A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Quiz with score system

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    2

    Quiz with score system

    I'm trying to make a simple quiz in cs6 with actionscript 2.0. Basically there are 8 questions and each question has 3 possible answers. For each answer I want to assign a different score. Depending on the total score, a different text is displayed at the end of the quiz. What is the best/easiest way to code this? Graphically-wise, the quiz is as good as finished (as it's pretty basic) and I already have programmed the actions of clicking the 3 possible answer buttons and the start button etc. I only don't know how to make this score system. I found someone who already asked my question here but he didn't really get much of an answer nor did I understand his code. Can somebody please help me out? I'd really appreciate it. Thanks in advance.

    I added this to one of the buttons in the beginning:

    Code:
    on (release) {
    _global.score=0;
    _global.score=_global.score+x;
    }
    At the last couple questions I added this script (it's supposed to view a template with the result of the quiz based on the total score):

    Code:
    on (release) {
    if (score<=x) {
        gotoandstop(y);
    } else if (score=x or x or x or x) {
        gotoandstop(y);
    } else if (score>=x) {
        gotoandstop(y);  
    } else {
        gotoandplay(y);
    }
    I replaced the actual numbers with x and y because you obviously can't know how I organized the templates. But somehow in the last script the total score calculation doesn't give the correct result...

    Can someone PLEASE help me, it's urgent.

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Firstly you might want to put this on the timeline by itself, im not sure.

    _global.score = 0;

    then on the two of your buttons have these codes
    PHP Code:
    on (release) {
        if (
    score <= || score >= x)
        {
            
    gotoAndStop(y);
        }
        else if (
    score == || score == || score == || score == x)
        {
            
    gotoAndStop(y);
        }
        else
        {
            
    gotoAndPlay(y);
        }

    PHP Code:
    on (release) {
        
    _global.score _global.score x;

    gotoandplay should be gotoAndPlay, gotoandstop should gotoAndStop, capitals, most important for it to work.

    good luck


    code explained
    PHP Code:
    on (release) {
        
    // if score less than, equal to, or higher than **
        
    if (score <= || score >= x)
        {
            
    gotoAndStop(y);
        }
        
    // if score is equal to ** or score is equal to ** or ** or **
        
    else if (score == || score == || score == || score == x)
        {
            
    gotoAndStop(y);
        }
        
    // if score not similar to any of the above
        
    else
        {
            
    gotoAndPlay(y);
        }


  3. #3
    Junior Member
    Join Date
    Oct 2013
    Posts
    2

    Thumbs up

    Thanks a bunch man, I finally got it right!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center