Actionscript Code:
i = 0;
n = 4;
rump = 0;
crown = 0;
sides = 0;
yolk = 0;
points = 0;
correct = false;
down = false;
this.onMouseMove = function()
{
if(down && i < 4){
mc.clear();
mc.lineStyle(2, 0xFFFF00, 100);
mc.moveTo(x0,y0);
mc.lineTo(_xmouse,_ymouse);
updateAfterEvent();
}
};
onMouseDown = function(){
if(i < 4){
attachMovie("marker_mc", "marker"+i, i, {_x:_xmouse, _y:_ymouse});
if(rump_bt.hitTest(_xmouse, _ymouse, true)){
rump = 1;
} else if(crown_bt.hitTest(_xmouse, _ymouse, true)){
crown = 1;
} else if(sides_bt.hitTest(_xmouse, _ymouse, true)){
sides = 1;
} else if(Yolk_bt.hitTest(_xmouse, _ymouse, true)){
yolk = 1;
}
if(i == 0){
if(sides == 1){
points++;
}
} else if(i == 1){
if(yolk == 1){
points++;
}
} else if(i == 2){
if(rump == 1){
points++;
}
} else if(i == 3){
if(crown == 1){
points++;
}
}
if(points == 4){
correct = true;
}
i++;
}
mc = this.createEmptyMovieClip("mc" + n, n);
n++;
x0 = _xmouse;
y0 = _ymouse;
}
onMouseUp = function(){
if(i == 4){
submit_bt._visible = true;
diff1X = marker1._x - marker0._x;
diff1Y = marker1._y - marker0._y;
diff2X = marker3._x - marker2._x;
diff2Y = marker3._y - marker2._y;
diff1 = (Math.atan2(diff1Y, diff1X)*180/Math.PI)+180;
diff2 = (Math.atan2(diff2Y, diff2X)*180/Math.PI)+180;
difference = Math.abs(diff1-diff2);
trace(difference);
degree.text = difference;
}
x0 = _xmouse;
y0 = _ymouse;
down = !down;
}
background_bt._visible = false;
reveal_a._visible = false;
reveal_b._visible = false;
reveal_bt._visible = false;
reveal_bt._visible = false;
retry_bt._visible = false;
submit_bt._visible = false;
yolk_arrow._visible = false;
cover_bt._visible = false;
submit_cover._visible = false;
cd_dash._visible = false;
ab_dash._visible = false;
cover_bt.useHandCursor = false;
ended = false;
Yolk_bt._visible = false;
rump_bt._visible = false;
crown_bt._visible = false;
sides_bt._visible = false;
submit_bt.onRelease = function() {
ended = true;
if((difference > 85) && (difference < 95) && (correct == true))
//The angle between the two lines is between 85 degrees and 95 degress and therefore correct and the 4 points are all correctly placed.
{
cover_bt._visible = true;
feedback.htmlText = "<b>Correct.</b>\n\nYou have correctly placed the two abdominal diameter measurements at the abdominal circumference and at right angles to each other.";
submit_bt._visible = false;
}
else if((difference < 85 || difference > 95) && (correct == true))
//The angle between the two lines is either less than 85 degrees or greater than 95 degress but the 4 points are all correctly placed.
{
feedback.htmlText = "<b>Incorrect.</b>\n\nRemember that the two measurements should be at right angles to each other.";
reveal_bt._visible = true;
retry_bt._visible = true;
submit_bt._visible = false;
}
else if((difference > 85) && (difference < 95) && (correct == false))
//The angle between the two lines is between 85 degrees and 95 degress and therefore correct but one/all of 4 points are incorrectly placed.
{
feedback.htmlText = "<b>Incorrect.</b>\n\nEach of the two measurements should touch the circumference of the abdomen.";
reveal_bt._visible = true;
retry_bt._visible = true;
submit_bt._visible = false;
}
//The angle between the two lines is either less than 85 degrees or greater than 95 degress and one/all of 4 points are incorrectly placed.
else if ((difference < 85 || difference > 95) && (correct == false))
{
feedback.htmlText = "<b>Incorrect.</b>\n\nRemember that the two measurements should be at right angles to each other and each of the two measurements should touch the circumference of the abdomen.";
reveal_bt._visible = true;
retry_bt._visible = true;
submit_bt._visible = false;
}}
reveal_bt.onRelease = function () {
for(a=0;a<i;a++){
removeMovieClip(_root["marker"+a]);
}
for(k=4;k<n+1;k++){
removeMovieClip(_root["mc"+k]);
}
ended = true;
feedback.htmlText = "";
ab_dash._visible = true;
cd_dash._visible = true;
retry_bt._visible = false;
cover_bt._visible = true;
reveal_bt._visible = false;
submit_bt._visible = false;
reveal_a._visible = true;
reveal_b._visible = true;
yolk_arrow._visible = false;
};
retry_bt.onRelease = function (){
for(a=0;a<i;a++){
removeMovieClip(_root["marker"+a]);
}
for(k=4;k<n+1;k++){
removeMovieClip(_root["mc"+k]);
}
n = 4;
points = 0;
degree.text = ""
i = 0;
rump = 0;
crown = 0;
sides = 0;
yolk = 0;
cd_dash._visible = false;
ab_dash._visible = false;
ended = false;
cover_bt._visible = false;
yolk_arrow._visible = false;
reveal_bt._visible = false;
retry_bt._visible = false;
feedback.htmlText = "";
submit_bt._visible = false;
}