A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Quiz coding help please

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    2

    Quiz coding help please

    Hello, (using AS2)
    I have pieced together this multiple choice quiz and am not getting the result I need....stumped and been looking at it too long.

    Here's the setup:
    10 questions, each question adds a 1-5 points depending on the answer you select i.e. a=1, b=2..... This works fine.

    When you answer question 10, I want the viewer to be taken to 1 of four frames that show them their score. The reason for the frames (frames that have labels assigned to them) is b/c the total sum is broken down into four parts.....Sounds crazy confusing...sorry

    If you score 10-20 you go to a specified label, if you score 21-30 you go to a different label and so on....Making sense?

    I have been getting help with this and some code is a bit beyond my knowledge so I'm 1/2 getting int 1/2 confused.

    Attached is file, please help, thanks in advance.
    Attached Files Attached Files

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    // on button 1
    on (release) {
    	yourScore = yourScore+1;
    	finalScore = yourScore;
    	if ((finalScore>=10) && (finalScore<=20)) {
    		gotoAndStop("score");
    	} else if ((finalScore>20) && (finalScore<=30)) {
    		gotoAndStop("score2");
    	} else if ((finalScore>30) && (finalScore<=40)) {
    		gotoAndStop("score3");
    	} else if ((finalScore>40) && (finalScore<=50)) {
    		gotoAndStop("score4");
    	}
    }
    // on button 2
    on (release) {
    	yourScore = yourScore+2;
    	finalScore = yourScore;
    	if ((finalScore>=10) && (finalScore<=20)) {
    		gotoAndStop("score");
    	} else if ((finalScore>20) && (finalScore<=30)) {
    		gotoAndStop("score2");
    	} else if ((finalScore>30) && (finalScore<=40)) {
    		gotoAndStop("score3");
    	} else if ((finalScore>40) && (finalScore<=50)) {
    		gotoAndStop("score4");
    	}
    }
    
    // etc...

  3. #3
    Junior Member
    Join Date
    Jun 2010
    Posts
    2

    thanks it worked!

    Thanks for the help, that did it....argh! it's always the placement of code that gets me. Thanks for quick responce!

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    wouldn't something like this be simpler (assuming 'score' is renamed 'score1)

    Actionscript Code:
    gotoAndStop("score" + ((finalScore - finalScore%10)/10));

    dawsonk?

    gparis

  5. #5
    :
    Join Date
    Dec 2002
    Posts
    3,518
    gparis,

    Yes, much simpler. Just posted the fixes to the existing code. The whole file needs to be optimized, but didn't have the time to do that.

    Thanks.

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