# EventDispatcher: Getting Rid of the Events

**URL:** https://forum.kirupa.com/t/eventdispatcher-getting-rid-of-the-events/190972
**Category:** flash
**Created:** [June 16, 2006, 1:09am UTC](https://forum.kirupa.com/t/eventdispatcher-getting-rid-of-the-events/190972 "2006-06-16T01:09:36Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![McGuffin](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mcguffin/32/408_2.png) [@McGuffin](https://forum.kirupa.com/u/McGuffin)
#### Post date: [June 16, 2006, 1:09am UTC](https://forum.kirupa.com/t/eventdispatcher-getting-rid-of-the-events/190972/1 "2006-06-16T01:09:36Z")

</div>

Theory question, more than anything.

```auto

var page = _root["pageinstance"+num]; //num is a variable, duh.
//
page_li:Object = new Object(); // page_listener object
page_li.onPageLoad = function() {
    trace("hey, look, the page loaded");
    page.display();
}
page_li.onPageDisplay = function() {
    trace("look at that! The page displayed!");
}
//
page.addEventListener("onPageLoad", page_li);
page.addEventListener("onPageDisplay", page_li);
page.load();

```

The code is much more complex than this, but thats the skeleton of it. Anyone, my question to you is that I need to use this over and over again, for each time the user presses a button. My problem is that Flash seems to have trouble when I try visiting a page I’ve already been to, because the events don’t properly execute. I’ve tried page.removeEventListener(); and delete page\_li; but both seem to be ineffective.

Basically, what I’m asking is how can I whip the slate completely clean, so that the next time when Flash goes over this code, it executes properly?

Thanks a lot.
