Matching Game - adding a delay to correct answers
I really like the book and am finding really useful learning on the job.
I am a primary school teacher and am adapting the matching game for my students.
I have created a game where the children match a simple equation to an answer, however to work it really needs to pause on the correct match, to allow some time for reflection.
I has hoped adding the following to the existing code would work:
// compare two cards
if (Math.floor(firstCard.cardface/2) == Math.floor(secondCard.cardface/2)) {
// remove a match
correctanswer = new Timer(2000,1);
correctanswer.addEventListener(TimerEvent.TIMER_COMPLETE,(removecorrect));
correctanswer.start();
function removecorrect(event:TimerEvent){
removeChild(firstCard);
removeChild(secondCard);}
However the cards are not being removed after the match as I had hoped. Instead I get the message:
TypeError: Error #2007: Parameter child must be non-null.
Any suggestions as to how to add the delay would be gratefully received.
Copyright Gary Rosenzweig
