# Saving data when user closes app

**URL:** <https://forum.kirupa.com/t/saving-data-when-user-closes-app/151259>\
**Category:** flash\
**Created:** [June 14, 2005, 1:27pm UTC](https://forum.kirupa.com/t/saving-data-when-user-closes-app/151259 "2005-06-14T13:27:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrscote](https://avatars.discourse-cdn.com/v4/letter/c/e8c25b/32.png) [@chrscote](https://forum.kirupa.com/u/chrscote)\
**Post date:** [June 14, 2005, 1:27pm UTC](https://forum.kirupa.com/t/saving-data-when-user-closes-app/151259/1 "2005-06-14T13:27:40Z")

</div>

I have a Flash application in which I have a close button. When the user hits the Flash close button, I then need to save some data, including the time of the closing and any other data that’s been saved over the course of a tutorial like errors they’ve made. However, if the student uses the Windows close functionality (Alt-F4 or X on browser window), I want to have an alert display telling the user to cancel the close.  
Now, I’ve seen other posts elsewhere that I can use the onBeforeUnload to alert the user, but I get this alert even if they use the Flash close. Can I set a variable within the HTML page’s javascript so that the page won’t display the alert? And if so, how do I do that?

Chris
