Skip to main content
Participant
August 19, 2014
Question

drag and drop with user feedback

  • August 19, 2014
  • 1 reply
  • 360 views

I created a drag and drop game where users drop sections on a map and instantly receive feedback if they are correct or incorrect.  I've got the correct feedback working correctly but I can figure out the incorrect part as it is below nothing happens.  Any help is greatly appreciated


------------------------------


stop();

_global.counter=1;

_global.totalquestions=10;

Slogan1="Question 1";

Slogan2="Question 2";

Slogan3="Question 3";

Slogan4="Question 4";

Slogan5="Question 5";

Slogan6="Question 6";

Slogan7="Question 7";

Slogan8="Question 8";

Slogan9="Question 9";

Answer1="Box_A";

Answer2="Box_B";

Answer3="Box_C";

Answer4="Box_D";

Answer5="Box_E";

Answer6="Box_F";

Answer7="Box_G";

Answer8="Box_H";

Answer9="Box_I";

function init(){

_root.slogan.text=Slogan1;

_global.answer=Answer1;

_global.counter++;

}

function checkAnswer(guess){

if (guess==_global.answer){

_root.slogan.text=eval("Slogan"+_global.counter);

_global.answer=eval("Answer"+_global.counter);

_global.counter++;

//_root.result.text="You Are Correct";

feedback("correct");

eval("_root." + guess)._alpha=70;

eval("_root." + guess).active=0;

if (_global.counter > _global.totalquestions){

_root.complete.text="Quiz Complete";

_root.slogan.text="Quiz Complete";

  }

}else{

//_root.result.text="You Are Wrong";

feedback("incorrect");

  }

}

init();

function feedback (response){

  _root.correct._visible=0;

  _root.incorrect._visible=0;

  clearInterval (_global.feedTime);

   if (response=="correct")

   {_root.correct._visible=1;

     }else{

   _root.incorrect._visible=1;

   }

   _global.feedTime=setInterval (clearFeed, 1000, response);

  

   }

  

function clearFeed(response){

  eval("_root."+response)._visible=0;

  clearInterval (_global.feedTime);

}

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
August 19, 2014

use the trace function to debug.


stop();

_global.counter=1;

_global.totalquestions=10;

Slogan1="Question 1";

Slogan2="Question 2";

Slogan3="Question 3";

Slogan4="Question 4";

Slogan5="Question 5";

Slogan6="Question 6";

Slogan7="Question 7";

Slogan8="Question 8";

Slogan9="Question 9";

Answer1="Box_A";

Answer2="Box_B";

Answer3="Box_C";

Answer4="Box_D";

Answer5="Box_E";

Answer6="Box_F";

Answer7="Box_G";

Answer8="Box_H";

Answer9="Box_I";

function init(){

_root.slogan.text=Slogan1;

_global.answer=Answer1;

_global.counter++;

}

function checkAnswer(guess){

trace(guess+" "+_global.answer);

if (guess==_global.answer){

_root.slogan.text=eval("Slogan"+_global.counter);

_global.answer=eval("Answer"+_global.counter);

_global.counter++;

//_root.result.text="You Are Correct";

feedback("correct");

eval("_root." + guess)._alpha=70;

eval("_root." + guess).active=0;

if (_global.counter > _global.totalquestions){

_root.complete.text="Quiz Complete";

_root.slogan.text="Quiz Complete";

  }

}else{

//_root.result.text="You Are Wrong";

trace("incorrect");

feedback("incorrect");

  }

}

init();

function feedback (response){

  _root.correct._visible=0;

  _root.incorrect._visible=0;

  clearInterval (_global.feedTime);

   if (response=="correct")

   {_root.correct._visible=1;

     }else{

trace("incorrect and code is working")

   _root.incorrect._visible=1;

   }

   _global.feedTime=setInterval (clearFeed, 1000, response);

 

   }

 

function clearFeed(response){

  eval("_root."+response)._visible=0;

  clearInterval (_global.feedTime);

}

Participant
August 19, 2014

When I do that this is displayed - Box_A Box_A.  So the correct part is working but something is wrong with the incorrect that I cant seem to figure out.


stop();

_global.counter=1;

_global.totalquestions=10;

Slogan1="Question 1";

Slogan2="Question 2";

Slogan3="Question 3";

Slogan4="Question 4";

Slogan5="Question 5";

Slogan6="Question 6";

Slogan7="Question 7";

Slogan8="Question 8";

Slogan9="Question 9";

Answer1="Box_A";

Answer2="Box_B";

Answer3="Box_C";

Answer4="Box_D";

Answer5="Box_E";

Answer6="Box_F";

Answer7="Box_G";

Answer8="Box_H";

Answer9="Box_I";

function init(){

_root.slogan.text=Slogan1;

_global.answer=Answer1;

_global.counter++;

}

function checkAnswer(guess){

trace(guess+" "+_global.answer);

if (guess==_global.answer){

_root.slogan.text=eval("Slogan"+_global.counter);

_global.answer=eval("Answer"+_global.counter);

_global.counter++;

//_root.result.text="You Are Correct";

feedback("correct");

eval("_root." + guess)._alpha=70;

eval("_root." + guess).active=0;

if (_global.counter > _global.totalquestions){

_root.complete.text="Quiz Complete";

_root.slogan.text="Quiz Complete";

  }

}else{

//_root.result.text="You Are Wrong";

trace("incorrect");

feedback("incorrect");

  }

}

init();

function feedback (response){

  _root.correct._visible=0;

  _root.incorrect._visible=0;

  clearInterval (_global.feedTime);

   if (response=="correct")

   {_root.correct._visible=1;

     }else{

  trace("incorrect and code is working")

   _root.incorrect._visible=1;

   }

   _global.feedTime=setInterval (clearFeed, 1000, response);

  

   }

  

function clearFeed(response){

  eval("_root."+response)._visible=0;

  clearInterval (_global.feedTime);

}

kglad
Community Expert
Community Expert
August 19, 2014

well, what do you see when you drop an incorrect object?