A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: call a function when user closes your swf

  1. #1
    Senior Member
    Join Date
    Jul 2008

    call a function when user closes your swf

    how do you call to a function when the user closes your swf?

    Probably some kind of event. I couldn't find it.

    I program in AS3 only.

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Austin, TX
    There is no such event. For that matter, there is no such thing as closing a swf. In the standalone player, you close the player. In a web browser, you navigate away from the page.

    You could attempt to use javascript to catch the unload event when the user leaves the page, and then call into the swf with a method exposed by ExternalInterface, but the user is still leaving the page, and whatever you're doing will probably not get to finish.

    There is also the Event.UNLOAD event dispatched by loaderInfo, but that occurs when your swf is unloaded from a loader. I don't think it is actionable when the user navigates away.

  3. #3
    Junior Member
    Join Date
    Jun 2010
    Use timer. if user 1-2 minutes do not change a position of the mouse or not key down - he left.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center