1 Reply Latest reply on Jun 5, 2014 5:21 AM by jfb00

    How to check whether an internet/network connection available or not only for once

    Udit bhardwaj

      How Can I check for an internet connection is available or not but Only For ONCE (One Time)

       

      I am using the following code but it is continuously monitoring the  availability for the internet connection . I want to run it (execute) it only for once   How can i do it or there is a way to check for a function that it has been executed or not with the help of boolean type Variable

       

      I have tried the loop for(i=0 to i = 1) but it  makes my application crash every time .

       

       

       

      private function init():void

        {

        NativeApplication.nativeApplication.addEventListener(Event.NETWORK_CHANGE, onNetworkChange);

        monitorConnection();

       

        }

       

        private function onNetworkChange(event:Event):void

        {

        trace('network change');

        monitorConnection();

        }

       

        private function monitorConnection():void

        {

        monitor = new URLMonitor(new URLRequest(strURLMonitor));

        monitor.addEventListener(StatusEvent.STATUS,announceStatus);

        monitor.start();

        }

       

        private function announceStatus(e:StatusEvent):void {

        trace("Status change. Current status: " + monitor.available);

        if(monitor.available)

        {

           // Do something

       

      }

        else

        {

           // Do something else

        }

        }

       

       

      Thanks

      Udit Bhardwaj