Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

drag and drop with user feedback

New Here ,
Aug 19, 2014 Aug 19, 2014

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);

}

TOPICS
ActionScript
322
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 19, 2014 Aug 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);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 19, 2014 Aug 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);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 19, 2014 Aug 19, 2014

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 19, 2014 Aug 19, 2014

nothing

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 19, 2014 Aug 19, 2014

then you're not calling checkAnswer() when you drop an incorrect object.

what code executes when an object is dropped?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 19, 2014 Aug 19, 2014

This is the code on every object that is dropped, there are 9 of them. 

onClipEvent (load) {

  this.active = 1;

  origX = this._x;

  origY = this._y;

}

onClipEvent (mouseDown) {

  if (this.hitTest(_root._xmouse, _root._ymouse))

  {

  if (this.active == 1)

  {

  this.startDrag();

  }

  }

}

onClipEvent (mouseUp){

  if (this.active == 1)

  {

  if (this.hitTest(_root._xmouse, _root._ymouse))

  {

     // see if the dropZone conatins the center of this mc

  if (_parent.dropZone_A.hitTest(this._x, this._y, true))

  {

  _root.checkAnswer(this._name);

  origX = 285.95;

  origY = 230.00;

  }

  }

  }

  this._x = origX;

  this._y = origY;

  this.stopDrag();

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 19, 2014 Aug 19, 2014
LATEST

that's not good coding.

but the problem is probably,

  if (_parent.dropZone_A.hitTest(this._x, this._y, true))

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines