A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Else is unexpected

  1. #1
    Registered User
    Join Date
    Jul 2013
    Posts
    6

    Else is unexpected

    Hi all, I'm making a quiz and wanted to highlight the correct answer with green and red if it's wrong. But when i right the else statement it comes up else in unexpected.


    Code:
     btnCheck.addEventListener(MouseEvent.CLICK, chkAnswer);
    
    function chkAnswer(mevt:MouseEvent):void {
    	//if (cdlCorrect[index] == cdlUserAnswers[index]) {
          //trace ("index = ", index); 	
    		cdlDone[index] = 1;
    		var rectSize:uint = 300; 
    		var correctRect:Shape = new Shape();
    		var wrongRect:Shape = new Shape();
    		correctRect.graphics.beginFill(0x00FF00, 0.5); 
    		wrongRect.graphics.beginFill(0xFF0000, 0.5);
    
    		//if(cdlUserAnswers[index] == 0) {		
    
     //}
            if(cdlCorrect[index] == "0") {
            correctRect.graphics.drawRect(45, 50, rectSize, 25);      		
     }
            if(cdlCorrect[index] == "1") {
            correctRect.graphics.drawRect(45, 85, rectSize, 25);      
    		
     }
     	if(cdlCorrect[index] == "2") {
            correctRect.graphics.drawRect(45, 120, rectSize, 25);     
    		
     }
     	if(cdlCorrect[index] == "3") {
            correctRect.graphics.drawRect(45, 155, rectSize, 25);      
     }
    		if (cdlCorrect[index] == cdlUserAnswers[index]) {
    }
    	    qHolder.addChild(correctRect);
    			
    	//}
    	else {
    		//correctRect.visible = false;
    	//}
    }
    		
    		if(cdlUserAnswers[index] == "0") {
            wrongRect.graphics.drawRect(45, 50, rectSize, 25); 
     }
            if(cdlUserAnswers[index] == "1") {
            wrongRect.graphics.drawRect(45, 85, rectSize, 25);      
    		
    }
            if(cdlUserAnswers[index] == "2") {
            wrongRect.graphics.drawRect(45, 120, rectSize, 25);      
    
    }
            if(cdlUserAnswers[index] == "3") {
            wrongRect.graphics.drawRect(45, 155, rectSize, 25);
    }		
    		if (cdlCorrect[index] != cdlUserAnswers[index]) {
            
    }
    		qHolder.addChild(wrongRect);

  2. #2
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    this one?
    Code:
    	//}
    	else {
    		//correctRect.visible = false;
    	//}
    who is this? a word of friendly advice: FFS stop using AS2

  3. #3
    Registered User
    Join Date
    Jul 2013
    Posts
    6
    Yes realMakc, and I commented that else statement out but it still come up as an error

  4. #4
    Registered User
    Join Date
    Jul 2013
    Posts
    6
    It has been figured out. But now my problem is how to set up an if else statement if the user didn't select any answer and just clicked on the Show Me the Answer button. If he didn't select any answer, the correctRect must still show up but not the wrongRect (right now the wrongRect shows).

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