Help with document class as file syntax

The following lines of code were on the main timeline and now need to go in a document class .as file…
How do I re-write them properly?

closebutton.addEventListener(MouseEvent.CLICK, unloadFunction);

**function unloadFunction(event:MouseEvent) {
dispatchEvent(new Event(“UnloadMe”, true));
}

**