PDA

View Full Version : remove frame event?


runtime
05-17-2008, 03:11 AM
Hello,
I have a chopper_mc that is being controlled by the arrow keys. it basically flips one direction or another.
another mask_mc is always following it by being repositioned behind it when it flips. because the user can move the mc around i need a frame event so that it constantly updates x and y based on the position of chopper_mc.

It works fine on Frame 1, then fine again on frame 2. but when the user makes chopper_mc go back to frame 1 it seems that the spotChaseChopperR function takes over and it wont go back and forth.

is there any way to remove a frame event? or is there a better way to remove it?

frame 1:
stop();



function spotChaseChopperL(evt:Event):void {
MovieClip(root).mask_mc.x = Number(MovieClip(root).chopper_mc.x + 100);
MovieClip(root).mask_mc.y = Number(MovieClip(root).chopper_mc.y + 100);
}

addEventListener(Event.ENTER_FRAME, spotChaseChopperL); //



frame 2:
stop();


function spotChaseChopperR(evt:Event):void {
MovieClip(root).mask_mc.x = Number(MovieClip(root).chopper_mc.x -200);
MovieClip(root).mask_mc.y = Number(MovieClip(root).chopper_mc.y + 100);
}

addEventListener(Event.ENTER_FRAME, spotChaseChopperR);

Any help is appreciated in advance!

matbury
05-17-2008, 03:40 AM
removeEventListener(Event.ENTER_FRAME, spotChaseChopperL);

But I'd look into having just one enterFrame function and changing a variable in it with the arrow keys. It'll make your code much more efficient and easier to manage when your project gets more complicated.

runtime
05-17-2008, 03:51 AM
thanks for your help. that worked like a charm.

but, yes i am back to having one frame event on the main timeline and trying to make a condition and that will change the position for best practice.

thks again.