简体   繁体   中英

to create quiz using StartDrag and stopDrag

Actually i have a quiz.fla. In the file ,two of them fill inthe blank questions and others are
multiple questions.

square1_mc must run only once not twice. İf user correct selected, doesnt run it again. However,if mybadscoretext is 1 not increase 2,3,4. :S how i can do all?

stop();

var myScore:Number = 0;
var myBadScore:Number=0;

square1_mc.addEventListener(MouseEvent.MOUSE_DOWN, drag);
stage.addEventListener(MouseEvent.MOUSE_UP, drop);



function drag(e:MouseEvent):void
{
 e.target.startDrag();
}

function drop(e:MouseEvent):void
{

 square1_mc.stopDrag();
 if (square1_mc.hitTestObject(square2_mc)== true)
 {

square1_mc.x=129;
square1_mc.y=133;
 this.graphics.clear();
this.graphics.lineStyle(2, 000000);
this.graphics.moveTo(square1_mc.x, square1_mc.y);
this.graphics.lineTo(square2_mc.x, square2_mc.y);
this.graphics.endFill();


myScore += 1;
score_txt.text=String(myScore);
square1_mc.removeEventListener(MouseEvent.MOUSE_DOWN, drag);



 }

 else 
 { 

square1_mc.x=129;
square1_mc.y=133;
myBadScore += 1;
mybadscore_txt.text=String(myBadScore);


 }

}

Add a variable to keep track of whether the bad score has been added:

var badMarked:Boolean = false;

function drag(e:MouseEvent):void
{
    e.target.startDrag();
    badMarked = false;
}

[...]

function drop(e:MouseEvent):void
{
    if (square1_mc.hitTestObject(square2_mc)== true)
    {
    [...]
    }
    else if ( !badMarked  )
    { 
        square1_mc.x=129;
        square1_mc.y=133;
        myBadScore += 1;
        mybadscore_txt.text=String(myBadScore);
        badMarked = true;
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM