#8 Flex Hack – Detecting if a user is on-line or off-line in Flex without server-side tricks

Filed under Flex, Flex Beyound basic, Flex Hacks

You may saw some techniques to detect if a user is on-line or off-line using httpservices IO requests and define if is on or off. This hack is easy to handle that, because doesn’t use any of theses techniques, all code run in client side as same as Adobe AIR has.

What really happens behind stages? We use the Navigator DOM even for IE4+ and Firefox3 will works this way. Because the DOM allows me to do that.

Level:Intermediate

Requirements: Flex 3.x SDK

How to:



    
        
    

That’s it. You can use your imagination and you can do same technique for apply a status Bar for your navigator, or many other things. Try to do something different reading the DOM reference for Firefox; Is a good start.

4 Comments

  1. james lei
    Posted January 13, 2009 at 10:17 am | Permalink

    There is another way to define offline connection status using RemoteObject with alert prompt on fault. This is useful when the network suddenly down and the user trying to submit data online:

    MXML:

    AS3:
    //Use this for every new connection, if send fail, throw error alert.
    myservice.getOperation(’getConnect’).send();

    private function offlineHandler():void{
    Alert.show(’Service offline.’, ‘Service Error:’);
    }

    you will need to create services-config.xml for the destination. It is a bit over complex but useful when use with AMFPHP.

  2. james lei
    Posted January 13, 2009 at 10:19 am | Permalink

    Most blog would remove the arrow symbol, here the code to fill in the above post.

    MXML:
    (small than) mx:RemoteObject id=”myservice” fault=”offlineHandler(event)” source=”getConnect” destination=”amfphp”/ (greater than)

  3. Al
    Posted January 14, 2009 at 6:26 am | Permalink

    Sorry, but is some code missing? There seems to be an empty block with nothing in and a call to checkStatus in the button click.

    Perhaps I’m missing something but I’m not sure that’d work?

  4. Posted January 27, 2010 at 3:05 pm | Permalink

    View source on the browser — that pretty code box is fouling the source code :(

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*