我需要使用 flash 或 actionscript ping 网络 [英] I need to ping to an network with flash or actionscript

查看:20
本文介绍了我需要使用 flash 或 actionscript ping 网络的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 flash 中创建了一个网络故障排除工具.该设计将在屏幕上显示所有组件.我必须每分钟 ping 一次每个组件.我已经完成了设计部分.

I have created a network trouble shooting tool in flash. The design will have all the componenets on the screen. I have to ping to every component once in minute. I have finished the design part.

请有人帮助我如何在 flash 中 ping 一个网址或 IP.

Please someone help me how do i ping a webaddress or IP in flash.

我需要一个示例代码..我使用的是 Flash CS3

I need a sample code.. Im using Flash CS3

推荐答案

你说你把所有的组件都放在屏幕上,而且你必须在一分钟内 ping 每个组件一次是什么意思?

What do you mean by you have all the components on the screen and you have to ping every component once in a minute?

如果 ping 你的意思是一个应用程序,什么检查一个 url 的时间响应,那么你可以尝试使用以下代码:

If by ping you mean an app, what checks the time-response of a url, then you can try to play with this code:

var ldr:URLLoader = new URLLoader();
ldr.addEventListener(HTTPStatusEvent.HTTP_STATUS, ldrStatus);

var url:String = "URL-TO-SITE";
var limit:int = 10;

var time_start:Number;
var time_stop:Number;
var times:int;

ping();

function ping():void
{
    trace("pinging", url);

    times = 0;
    doThePing();
}

function doThePing():void
{
    time_start = getTimer();
    ldr.load(new URLRequest(url));
}

function ldrStatus(evt:*):void
{
    if(evt.status == 200)
    {
        time_stop = getTimer();
        trace("got response in", time_stop - time_start, "ms");
    }

    times++;
    if(times < limit) doThePing();
}

这没什么特别的,URLLoader 尝试加载 url,并监听响应.如果 status200,则成功ping".或者乒乓球.

This is nothing special, the URLLoader tries to load the url, and listens to the response. If the status is 200, then got a successful "ping". Or pong.

另一方面,您始终可以运行服务器端 ping 程序,并使用闪存进行控制.

On the other hand, you can always run a server-side ping program, and control that with flash.

如果您的意思是一个应用程序,例如上传下载速度测试器,它也以类似的内容开头,而是以 Loader 对象.

If you mean an app, like an upload-download-speedtester, that also starts with something like this, but rather with the Loader object.

希望这会有所帮助.

防止缓存问题,可以使用:

Preventing cache problems, you can use:

ldr.load(new URLRequest(url + "?rnd="+Math.random()));

现在,此页面可能不会返回网站的确切内容,但可能足以估计响应时间.带闪光灯.

Now, this page might not give back the exact content of a site, but might be good enough to estimate the response time. With flash.

总的来说,这可以清除缓存并每次加载站点以获得更好的结果.

So overall, this could clear the cache and load the site everytime to give a better result.

这篇关于我需要使用 flash 或 actionscript ping 网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆