ActionScript 2.0 - How do I stop hitTest detection after an event?
iHatePopUps
Singapore
if(this.hitTest(hitArea_0_mc)) { //If [answer] hits the [first hitArea]
//snap [answer] to the hitArea's position
this._x = hitArea_Array[0].xCoordinate;
this._y = hitArea_Array[0].yCoordinate;
validAngleFlag = true; //If [answer] hits a hit area, then set it to [true]
if(this._name == "boilingBtn_mc") {
trace("Oops, try again!");
this.slideTo(initial_boiling_x, initial_boiling_y, 0.5, "easeInSine", 0, callback);
}
else if(this._name == "freezingBtn_mc") {
trace("Oops, try again!");
this.slideTo(initial_freezing_x, initial_freezing_y, 0.5, "easeInSine", 0, callback);
}
else if(this._name == "sublimationBtn_mc") {
trace("Oops, try again!");
this.slideTo(initial_sublimation_x, initial_sublimation_y, 0.5, "easeInSine", 0, callback);
}
else if(this._name == "meltingBtn_mc") {
trace("Oops, try again!");
this.slideTo(initial_melting_x, initial_melting_y, 0.5, "easeInSine", 0, callback);
}
else if(this._name == "condensationBtn_0_mc" or this._name == "condensationBtn_1_mc") {//SPECIAL, There is [2] slots with the same answer
trace("Congrats, you got it right man!");
//Since [answer] is placed in the correct position, it [CAN'T] be move anymore! (As stated in the storyboard)
delete this.onPress;
delete this.onRelease;
tick1._visible = true;
condensation_01_correct = true;
}
}
Sorry if it's against the rules to put code here. It's my 1st time in this section of short-media. Anyway, i'm doing an educational activity for schoolkids learning simple physics and i've met up with a problem. This activity is in a 'drag-answer-and-drop-on-box' format and I've got 2 questions that has 'condensation' as answers, meaning 2 boxes (movieclips) to drop to. I've duplicated the 'condensation' MCs (to a total of 2 MCs, 1 for each box). The thing is, I found out that I can drop BOTH 'condensation' movieclips into the same 'box'. How can I edit my code so that when 1 box has the correct answer in it, it doesn't call hitTest() anymore?
P.S, i'm debugging this code for some previous programmer - I didn't write it. The chunk above are the if/else statements for a single 'answer' box. I've also included his comments.
//snap [answer] to the hitArea's position
this._x = hitArea_Array[0].xCoordinate;
this._y = hitArea_Array[0].yCoordinate;
validAngleFlag = true; //If [answer] hits a hit area, then set it to [true]
if(this._name == "boilingBtn_mc") {
trace("Oops, try again!");
this.slideTo(initial_boiling_x, initial_boiling_y, 0.5, "easeInSine", 0, callback);
}
else if(this._name == "freezingBtn_mc") {
trace("Oops, try again!");
this.slideTo(initial_freezing_x, initial_freezing_y, 0.5, "easeInSine", 0, callback);
}
else if(this._name == "sublimationBtn_mc") {
trace("Oops, try again!");
this.slideTo(initial_sublimation_x, initial_sublimation_y, 0.5, "easeInSine", 0, callback);
}
else if(this._name == "meltingBtn_mc") {
trace("Oops, try again!");
this.slideTo(initial_melting_x, initial_melting_y, 0.5, "easeInSine", 0, callback);
}
else if(this._name == "condensationBtn_0_mc" or this._name == "condensationBtn_1_mc") {//SPECIAL, There is [2] slots with the same answer
trace("Congrats, you got it right man!");
//Since [answer] is placed in the correct position, it [CAN'T] be move anymore! (As stated in the storyboard)
delete this.onPress;
delete this.onRelease;
tick1._visible = true;
condensation_01_correct = true;
}
}
Sorry if it's against the rules to put code here. It's my 1st time in this section of short-media. Anyway, i'm doing an educational activity for schoolkids learning simple physics and i've met up with a problem. This activity is in a 'drag-answer-and-drop-on-box' format and I've got 2 questions that has 'condensation' as answers, meaning 2 boxes (movieclips) to drop to. I've duplicated the 'condensation' MCs (to a total of 2 MCs, 1 for each box). The thing is, I found out that I can drop BOTH 'condensation' movieclips into the same 'box'. How can I edit my code so that when 1 box has the correct answer in it, it doesn't call hitTest() anymore?
P.S, i'm debugging this code for some previous programmer - I didn't write it. The chunk above are the if/else statements for a single 'answer' box. I've also included his comments.
0
This discussion has been closed.
Comments