Function invoked when closing projector using the default window close button

Hello guys! I am just having some little problem in dealing with this.

I am making a flash application and I am trying to find function to
use when I press the close button of the projector window. I dont
want to make a button that uses fscommand(“quit”) since this would be
impractical knowing that a default close button on the window is
already available. Anyway the purpose of the function is that when I
close my application, a dialog box/message would appear as a reminder
that some data has not yet been saved and give the user an option to
save or quit the application. I would appreciate any help. I tried
searching and I can not find any third party software that can do such
task. Thanks in advance.