How do I check for an active internet connection in Flash using Actionscript 3?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
If you are using AIR, you can use the ServiceMonitor
class.
Otherwise you might want to consider rolling your own with a URLLoader
coupled with a timer with an exponential backoff.
回答2:
to expand on martineno's answer about rolling your own using the URLLoader, read about the HTTPStatusEvent in the documentation.
at the end of the document Adobe includes an example for checking for the existence of a file on a server, but the same could be applied to simply check for an internet connection.