Julien,

Not sure what you're really trying to do here.  A bit more of a
description would be useful.  I'll take a shot anyway.

I'm going to guess that you've got your application running in a
browser.  As such, you've got a couple options.

First, and most obviously, you could have a "close" button in your
application which logs you out or ends the chat or whatever.  Just
leech off of that event, and away you go.

Secondly, if you want to try to capture the closing of the browser
window, there's a javascript event that you'll want to capture and tie
it to a method in your application through the ExternalInterface.

Here's a quick snippet of something similar to what I use:

[Javascript]

window.onbeforeunload = browserClosing;

function browserClosing(event_)
{
   getSWF("MyTestApp").theBrowserIsClosing();
}

// Gets a reference to the specified SWF file by checking which browser is
// being used and using the appropriate JavaScript.
function getSWF(movieName)
{
   if (navigator.appName.indexOf("Microsoft") != -1)
      return window[movieName];
   else
      return document[movieName];
}

[/Javascript]

[MXML]

<mx:Application ... creationComplete="load();">
   <Script><![CDATA[
      private function load():void
      {
         if(ExternalInterface.available)
         {
            try
            {
               ExternalInterface.addCallback("theBrowserIsClosing",
theBrowserIsClosingHandler);
            }
            catch(e:Error){}
         }
      }

      private function theBrowserIsClosingHandler():String
      {
         //Do whatever needs to be done here.   
      }
   ]]></Script>
</mx:Application>

[/MXML]

When your user hits the browser's close button, the onbeforeunload
event will fire calling the javascript method 'browserClose' which in
turn will call the 'theBrowserIsClosing' method in your application.

Hope that gets you pointed in the right direction.  If not, be a bit
more specific about what you're trying to do.

Evan

--- In [email protected], "julien castelain" <[EMAIL PROTECTED]>
wrote:
>
> Hi all,
> 
> I was wondering if there was a way to be notified when the user
"leaves" or
> "quits" the application using AS3.
> 
> Thanks.
>


Reply via email to