I really have tried my hardest on this little problem, its been 2 weeks of long evenings and I know one of you more experienced AS3 developer would fix in a minute or two, well I hope.
So I have a very simple game with drag able objects that you let go of with MOUSEUP an animation plays then hits the subject and makes another animation (splat or something). With the hitTest only on one frame from inside the movie clip. (this works fine)
I am having problems removing said eventListener, I tried removing it at the end of the animation, so on the last from on the animation there would be AS saying removeEventListener from stage, but this didn’t work, so I tried removeEventListener after dynamically added the animation to the stage, still no joy.
I hoped it was something simple like- this.removeEventListener or currentTarget, but alas no.
I really can’t think of anything else,
for the love of AS please help.
An explanation would also be amazing I understand how people don’t have time so really any input would be greatly appreciated.
Below is my AS, if anyone wants to see the FLA, I can send it on, I am cool with sharing.
NB its probably quite evident I am a novice so please help me on my way….
import flash.display.MovieClip;
import flash.events.*;
var test:dart = new dart();
addChild(test);
circle.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
function fl_ClickToDrag(event:MouseEvent):void
{
circle.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
function fl_ReleaseToDrop(event:MouseEvent):void
{
circle.stopDrag();
addEventListener(Event.ENTER_FRAME, checkIfHitTest);
function checkIfHitTest(Event)
{
if (circle.hitTestObject(square))
{
trace("true, the circle and square are colliding");
var s:blood_splat = new blood_splat();
addChild(s);
s.x = mouseX;
s.y = mouseY;
**removeEventListener(Event.ENTER_FRAME,checkIfHitTest);**
}
else
{
trace("false, the circle and square are not colliding");
var s:blood_splat = new blood_splat();
addChild(s);
s.x = mouseX;
s.y = mouseY;
s.alpha = 0.1;
**removeEventListener(Event.ENTER_FRAME,checkIfHitTest);**
}
}
}
just do: