Skip navigation
aperio_chris
Currently Being Moderated

Action script help: Quiz that uses an array needs to be changed.

Mar 15, 2013 11:20 AM

Tags: #cs5.5 #actionscript #newbie

Hi,

 

I have a quiz that was created by someone else, and now I (inexperienced with flash) need to make some edits. The quiz has 4 questions, and each answer the user clicks on will show a green ball, and then other text appears to let them know if they are right or not. Also, when they click the right answer "next" appears in the bottom right corner.

 

Now I need to make the wrong answers red balls, and have the green ball only for the right answer. However it seems there is only one "green ball" and the code creates an array and that's all I can understand. I will need to make this changes to about 15 quiz questions, so hopefully the solution is something I can replicate easily on my own.

 

Thanks!

 

Here is the code:

 

function doAnswer(n){

    //d or 4 is the correct answer.

    var bArray:Array = n.split("_");//split the button's name to array

    var butNum = bArray[1];//retrieve the button's number from the array

    //reset any answers that may have already been answered

    for (i=1;i<=4;i++){

        var currAns = "ans1_" + i;//current looped mc answer

        var currBut = "btn_" + i;

        if (this[currAns].actv == 1){

            this[currAns].play();

        }

        if (this[currBut].actv == 1){

            this[currBut].play();

        }

    }

    this["ans1_" + butNum].play();

    if (butNum==4){

        next_mc._visible = 1;

    }else{

        next_mc._visible = 0;

    }

}

 

 

 

Flash CS5.5

 
Replies
  • kglad
    72,220 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 15, 2013 12:10 PM   in reply to aperio_chris

    how are the green balls created?

     
    |
    Mark as:
  • kglad
    72,220 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 15, 2013 3:12 PM   in reply to aperio_chris

    has does the image get added to the display to indicate a clicked answer?

     
    |
    Mark as:
  • kglad
    72,220 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 19, 2013 2:20 PM   in reply to aperio_chris

    not really.

     

    where in your code is adding that green ball done?  is that done by changing a frame in a movieclip?

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points