如何使用Adobe Air检查iPad上的互联网连接

时间:2019-03-12 09:40:25

标签: actionscript-3 flash actionscript air adobe

他们建议采用哪种方法来验证与互联网的连接?我已经尝试使用URLRequest或只是ping通,但未成功

import air.net.URLMonitor;

private var stateNet            : Boolean = true;
private var monitor             : URLMonitor;

功能:

public function checkInternetConnection():Boolean{
        monitor = new URLMonitor(new URLRequest('http://www.google.com/'));
        monitor.addEventListener(StatusEvent.STATUS, announceStatus);
        monitor.start();

        if(monitor.available == true){
            stateNet;
        }else{
            stateNet = false;
        }
        return stateNet;
    }

    public function announceStatus(e:StatusEvent):void {
        trace("Status change. Current status: " + monitor.available);
    }

“错误”: monitor.available始终为false

0 个答案:

没有答案