Flash 5: Actionscript: Need an OnUnload kind of function

Posted on 2004-10-02
Last Modified: 2012-08-13
I have a chat program. Works great.

I need an unload function though.

The chat program runs in the flash .exe format - and when someone clicks on the "X" to close the window, I need the program to connect to the server and log the user out.

The user can click on a logout button, but not many people will be doing that. :)

Any ideas?

I was hoping maybe flash had an OnUnload function like in Javascript.

Thanks :)
Question by:dr34m3rs
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
LVL 10

Expert Comment

ID: 12208257
I personally haven't seen a solution that works yet (I have looked at a few options), although I would like to.

There was a related discussion here: http:116#11893006 although it isn't entirely resolved, and if there is a solution it is more than likely it will use JavaScript like you mentioned.

Author Comment

ID: 12208408
Well javascript isn't an option in my case unless it can be called somehow with getURL("javascript:something()");

I was looking for any code that does something when the "X" is hit in an .exe format swf file (or on an UnLoad)

Thanks :)
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

LVL 10

Expert Comment

ID: 12208432
> I was looking for any code that does something when the "X" is hit in an .exe format swf file (or on an UnLoad)

There is no such option that I am aware of within a projector file, but this would be much more straightforward using either Director or Authorware as a host program, with your Flash embedded.  Then the onClose event can be captured using the Windows API functions, and flags sent back to Flash before the closure, to exit gracefully.

Expert Comment

ID: 12217033
Why dont you call the same script that you use for logout button onto the X button?

Thats like saying you have 2 logout button, one called LOGOUT and another called X. BOth doing the same thing.

Accepted Solution

ssdesign earned 250 total points
ID: 12217047
Sorry if i missunderstood, r u refering to the X button in on the porjector window?

If yes then try using something like, SCREENWEAVER (

Author Comment

ID: 12217427
Yes I meant the X button in the projector window itself :)

Sorry to not have made that more clear...

SCREENWEAVER looks neat, I will look into that and see if it solves that problem. =D

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question