Quiz Show results and start again

Lets write a code that check what is your final result, and will show you the response checking in the solutions array

public function showResult():Void
{
//** setting a var to add all the points for every page
var totalPoints:Number = 0
for(var i:Number = 1;i<=Quiz.quiz_content.length;i++)
{
var myValue:Number = new Number(this["quiz_page_w_"+i].myPoints)
totalPoints = totalPoints + myValue
}
//**lets use the function checkTheResults to see in which solution we are and receive back the number in the solutions array
var myResponse:Number = checkTheResults(totalPoints )
//attach the results movieClip and set his start value
results= this.attachMovie("results","results",999)
results._x = 400
results._y = 300
results.txt.autoSize = true;
results.txt.text = Quiz.solutions[myResponse].childNodes
results.title._xscale = 400
results.title._yscale = 400
results.txt._xscale = 400
results.txt._yscale = 400
results.txt._alpha = 0
results.title._alpha = 0
//**start the small animation to show the content of the result
results.title.alphaTo(100,.5,"linear")
results.title.tween("_yscale",100,.5,"easeOutCubic")
results.title.tween("_xscale",100,.5,"easeOutCubic")
results.txt.alphaTo(100,.5,"linear",.5)
results.txt.tween("_xscale",100,.5,"easeOutCubic",.5)
results.txt.tween("_yscale",100,.5,"easeOutCubic",.5)
//**set the restatrt button
results.startAgain.onRollOver = function()
{
this.colorTo(0xcccccc,0,"linear")
}
results.startAgain.onRollOut = function()
{
this.colorTo(0xffffff,0,"linear")
}
results.startAgain.onPress = Proxy.create(this,restartGame)

}

and lets add the method restartGame:

private function restartGame()
{
//**restart the game
var endA = {scope:this,func:destroyMc,args:[results]}
results.alphaTo(0,.5,"linear",0,endA)
setup()
}

in the show results method we will use this utilities to check which is the correct response, that we have to add at the end of the script:

private function checkTheResults(w_totalPoins:Number):Number
{
for(var i:Number = 0;i<Quiz.solutions.length;i++)
{
trace(Quiz.solutions[i].attributes.points_max)
var firstValue:Number =Quiz.solutions[i-1].attributes.points_max
var secondValue:Number =Quiz.solutions[i].attributes.points_max
trace("firstValue " + firstValue)
trace("secondValue" + secondValue)
if(firstValue==undefined)
{
firstValue = 0
}
if(w_totalPoins>firstValue and w_totalPoins<secondValue)
{
return i
}
}
}

Obviously don't forget to set the results variable results like a MovieClip and to do : import com.utilities.*;:

the final source. enjoy and take care!