A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Actionscript help on a Flash Quiz

  1. #1
    Junior Member
    Join Date
    Jul 2007
    Posts
    6

    Actionscript help on a Flash Quiz

    I'm working on a Flash quiz in MX 2004 and I want to add something, but I don't know where to start. I'm an Actionscript novice and I basically copied someone else's script and altered it to suit my needs up to this point. When it's done there will be 15 total questions (there are only two now but I'm working on the rest). Here's what I want to do:

    At the end of the quiz, if the user scores 13-15 I want the text "You are a Bordeaux Master!!!" to come up. If the score is 10-12 "You are a Bordeaux Pro". If 6-9 "You are a Bordeaux Apprentice" and 0-5 "You are a Bordeaux Novice".

    File attached. Any help would be much appreciated. Thanks.
    Attached Files Attached Files

  2. #2
    Senior Member
    Join Date
    Nov 2005
    Location
    dante's inferno
    Posts
    904
    revised grade user function:
    PHP Code:
    function gradeUser() {
      
    // Report that we're about to grade the quiz in the Output window.
      
    trace("Quiz complete. Now grading...");

      
    // Create a local variable to track the 
      // number of questions user answered correctly.
      
    var totalCorrect 0;      

      
    // Count how many questions the user answered correctly.
      // For each question...
      
    for (var i=0numQuestionsi++) {
        
    // If the user's answer matches the correct answer.
        
    if(userAnswers[i] == correctAnswers[i]) {
          
    // Give the user a point.
          
    totalCorrect++;
        }
        
    // Display the correct answer and the user's answer
        // in the Output window for debugging.
        
    trace("Question " + (1
             + 
    ". Correct answer: " correctAnswers[i]
             + 
    ". User's answer: "  userAnswers[i]);
      }

      
    // Display the final score in the Output window for debugging.
      
    trace("User's score: " totalCorrect "/" numQuestions);

      
    // Create an onscreen text field do display the user's score.
      
    this.createTextField("totalOutput_txt"50256040080);
      
       
      if ( 
    totalCorrect 13){
           
    totalOutput_txt.text "You answered  " totalCorrect "/" numQuestions " correctly."+newline+" You are a Bordeaux Master!!!";
      }else if(
    totalCorrect 10 && totalCorrect 12){
          
    totalOutput_txt.text "You answered  " totalCorrect "/" numQuestions " correctly."+newline+" You are a Bordeaux Pro.";
      }else if(
    totalCorrect >&& totalCorrect 9){
          
    totalOutput_txt.text "You answered  " totalCorrect "/" numQuestions " correctly."+newline+" You are a Bordeaux Apprentice.";
      }else if (
    totalCorrect >= && totalCorrect 5){
          
    totalOutput_txt.text "You answered  " totalCorrect "/" numQuestions " correctly."+newline+" You are a Bordeaux Novice.";
      }
          

      
    // Show the user's score in an onscreen text field.
      //totalOutput_txt.text = "You answered  " + totalCorrect + "/" + numQuestions + " correctly" ;

      // Customize the font face, size, and color of the text field.
      
    var format = new TextFormat();
      
    format.size 20;
      
    format.color 0xFFCC00;
      
    format.font "candara";
      
    format.bold true;
      
    totalOutput_txt.setTextFormat(format);

    I added:
    PHP Code:
    if ( totalCorrect 13){
           
    totalOutput_txt.text "You answered  " totalCorrect "/" numQuestions " correctly."+newline+" You are a Bordeaux Master!!!";
      }else if(
    totalCorrect 10 && totalCorrect 12){
          
    totalOutput_txt.text "You answered  " totalCorrect "/" numQuestions " correctly."+newline+" You are a Bordeaux Pro.";
      }else if(
    totalCorrect >&& totalCorrect 9){
          
    totalOutput_txt.text "You answered  " totalCorrect "/" numQuestions " correctly."+newline+" You are a Bordeaux Apprentice.";
      }else if (
    totalCorrect >= && totalCorrect 5){
          
    totalOutput_txt.text "You answered  " totalCorrect "/" numQuestions " correctly."+newline+" You are a Bordeaux Novice.";
      } 
    and comment out or delete this line:
    PHP Code:
    // Show the user's score in an onscreen text field.
      
    totalOutput_txt.text "You answered  " totalCorrect "/" numQuestions " correctly" 
    IMS

  3. #3
    Junior Member
    Join Date
    Jul 2007
    Posts
    6

    Thank you very much!!!

    IMS,
    I'm not one to use the word 'great' losely, but you are the greatest person who ever lived. Thanks so much for your help.

  4. #4
    Senior Member
    Join Date
    Nov 2005
    Location
    dante's inferno
    Posts
    904
    no problem.

    IMS

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