I am working on simple collaborative Flex application and I
need to know what users are running the application.
The idea is that once a user login a method updates an XML
file on the server listing the users ''connected''. Thus, in order to
update the file when a user closes the app., I would like to fire
an event on exit the app.
Is that possible? If ,so how?
This could be useful also to know how many concurrent users a
Flex application has.
Thanks,
GilbertIs there an onExit method available?
Because a flex app runs in the Flash Player in the browser,
you have to handle browser closing at the browser level.
ExternalInterface can notify your flex app, IF you can intercept
the browser closing event. IE has an ''onBeforeUnload'' (I think)
event that you can use. I don't know FF or the other browsers well
enough to have a suggestion.
TracyIs there an onExit method available?
Tracy,
Thanks. Even if FF has a similar event this approach can get
complex as it will need to have a command for each type of browser
and in some cases even versions of them.
I am thinking about another approach. Having a large (the
width of the browser window) and thin invisible button (really
transparent), that triggers an event when the user moves the mouse
to the top of the browser window. The event will write on the XML
file that the user is not be connected anymore. At the same time,
it also triggers a timer (that will trigger another event after a
couple of seconds) on the Flex app. that should write back to the
XML that the user still connected.
Is not perfect, but could work.
Any other suggestions?
Thanks,
Gilbert
I would not do that, (sorry but its too hacky, there are too
much variable things that can go wrong :
for example what if user closes browser with alt-f4?
or what if user just trying to move mouse to click on some
other buttons on browser bar?
I would definitely use a browser level code(javascript) there
are libraries that handle all major browser types look at some
annoying popups that promt you when you try to close them don't
they do the same thing you want?
levancho,
I guess you are rigth. The problem is I don't know about
those JavaScript libraries and how to call them from Flex.
Gilbert
take a look at this :
http://labs.adobe.com/wiki/index.php/Flex_Framework:FABridge
ana also this example :
http://flexapps.macromedia.com/labs/fabridge/samples/FABridgeSample.html
and also I think YUI library has that window closing event
you can register your javascript listener .
levancho,
Thanks. I will experiment with the FABridge.
Gilbert
Subscribe to:
Post Comments
(Atom)
No comments:
Post a Comment