DomingoSL
DomingoSL

Reputation: 15484

Is possible to remove an event listener in actionscript 3 (flash)?

In the frame 1 of my movie, part of my code is:

stage.addEventListener(Event.RESIZE, resizeHandler);

It works all fine, but when i go to the frame 2 the listener is still there but the function resizeHandler is not anymore (and i dont want it). So the console output this:

TypeError: Error #1009: Cannot access a property or method of a null object reference. at index_fla::MainTimeline/resizeHandler() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at flash.display::Stage/dispatchEvent() at index_fla::MainTimeline/frame2()

Is possible to remove the event listener on the frame 2? Thanks!!!

Upvotes: 0

Views: 1067

Answers (1)

Ben
Ben

Reputation: 355

In actionScript you can use:

stage.removeEventListener(Event.RESIZE, resizeHandler);

and that should remove your event handler.

Upvotes: 1

Related Questions