March 10, 2010

Pages


Search Site


Topics


Adobe AIR

ColdFusion

Flex

Adobe

ActionScript

Pet Rescues

My Links


Archives

AIR: Check if connected to the internet or not

June 23 2009 by Wally Kolcz

With most of my AIR apps connecting to the internet either to get or push data, having the ability to monitor the connection to the internet is vital to the success of the application. I am building an AIR app that allows my client to search images that she has on the web site from her laptop when she is at conferences. I decided to check the connectivity of the internet and have it enable or disable a 'search' button called 'search_btn'.

When the application is lauched I launch the functions below and they monitor the connection to the site constanty. If the connection is broken, the search button becomes disabled.

 

           public function startMonitoring():void {
                var monitor:URLMonitor = new URLMonitor(new URLRequest('http://www.med.umich.edu'));
                monitor.addEventListener(StatusEvent.STATUS, changeStatus);
                monitor.start();
            }


            public function changeStatus(e:Event):void {
                if (e.target.available){
                    search_btn.enabled = true;
                }else{
                    search_btn.enabled = false;
                }
            }

Posted in AIR | Flex | Flash | 1 comments

1 response to “AIR: Check if connected to the internet or not”

  1. car dealership connecticut Says:

    I often read your blog and always find it very interesting. Thought it was about time i let you know…Keep up the great work

Leave a Reply