Flash Quiz Drag and drop help
Hello, I have a Quiz where you drag a symbol over the correct answer, I have got it to work for a single question but I can't figure out how to get it to reset and work on the next frame with the new question.
Once the perosn chooses the correct answer a button apears allowing them to click onto the next question, if they get the wrong one then it shows the game over animation.In total I have 5 questions and after your get the final queston correct it shoudl go to a new frame where the winner animation plays. I'm not very good with scripting, sorry.
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.events.Event;
var myTimer:Timer = new Timer(1000,14)
var count:Number = 14
var startX:Number;
var startY:Number;
var counter:Number = 0;
stop();
nextbutton.visible=false;
Marker.buttonMode = true;
/*Timer*/
myTimer.addEventListener(TimerEvent.TIMER, countdown);
myTimer.start();
function countdown(event:TimerEvent):void {
txt_time.text = String((count)-myTimer.currentCount);
if(txt_time.text == "0"){
gotoAndPlay("Game_Over")
}
}
/*Quiz Marker*/
Marker.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
Marker.addEventListener(MouseEvent.MOUSE_UP, dropIt);
function pickUp(event:MouseEvent):void {
event.target.startDrag(true);
event.target.parent.addChild(event.target);
startX = event.target.x;
startY = event.target.y;
}
function dropIt(event:MouseEvent):void {
event.target.stopDrag();
var myTargetName:String = "Correct" + event.target.name;
var myTarget:DisplayObject = getChildByName(myTargetName);
if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
trace("testhere");
event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp);
event.target.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
event.target.x = myTarget.x;
event.target.y = myTarget.y;
counter++;
/*ANSWER WRONG*/
} else {
myTimer.stop()
gotoAndPlay("Game_Over");
Marker.visible=false
event.target.x = startX;
event.target.y = startY;
}
/*ANSWER CORRECT*/
if(counter == 1){
myTimer.stop();
nextbutton.visible=true;
Cig_Timer.stop();
event.target.x = startX;
event.target.y = startY
}
}
/*Next button*/
nextbutton.addEventListener(MouseEvent.CLICK, buttonClick_Quiz_Q2);
function buttonClick_Quiz_Q2(evt:MouseEvent):void {
gotoAndStop("Quiz_Q2");
}