So, I have code similar to this (this is for demonstration purposes):
addEventListener(Event.ENTER_FRAME, enterFrameFunction);
function enterFrameFunction(e:Event):void{
if(sampleMovieClip1.hitTestObject(sampleMovieClip2)){
runAFunctionIDontWantToBeRunOnEveryFrame();
}
}
The problem is that in order to test wether sampleMovieClip2 is colliding with sampleMovieClip1, I need to test it every frame with enterFrameFunction, so any code I put inside that function runs every frame the test returns true, but I want the runAFunctionIDontWantToBeRunOnEveryFrame(); function to only run it once.
I have been successful in doing this by adding a variable to determine if the condition has been true before, but i'm having complications with that now and would like to know if theres a different, less tedious way getting the result. Something like an event listener to test a boolean returning true?
Once the hit occurs you should remove the event listener.
Otherwise your only other solution would be
This does have a problem unsetting it back to false, non-stop when it's not hit, but will that make a problem?