Check connection in AS3


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. import air.net.URLMonitor;
  2. import flash.net.URLRequest;
  3. import flash.events.StatusEvent;
  4.  
  5. var monitor:URLMonitor = new URLMonitor(new URLRequest(‘http://www.enginyoyen.com’));
  6. monitor.addEventListener(StatusEvent.STATUS, checkHTTP);
  7. monitor.start();
  8.  
  9. function checkHTTP(e:StatusEvent) {
  10. if (monitor.available) {
  11. test_txt.text ="Internet is available";
  12. } else {
  13. test_txt.text ="No internet connection available";
  14. }
  15. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.