我创建了一个网络麻烦闪光灯拍摄工具。该设计将屏幕上的所有其它的组件。我必须在分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.
请帮助我的人我如何ping通在闪光灯webaddress或IP。
Please someone help me how do i ping a webaddress or IP in flash.
我需要一个样品code ..即时通讯使用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?
如果平安你的意思是一个应用程序,什么检查URL的时间响应,那么你可以尝试用此code玩:
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,并监听响应。如果状态
是 200
,然后得到了一个成功的平。还是乒乓球。
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.
如果你的意思是一个应用程序,比如上传下载-speedtester,也开始有这样的事情,而是用的装载机对象。
If you mean an app, like an upload-download-speedtester, that also starts with something like this, but rather with the Loader object.
希望这有助于。
编辑:
preventing缓存出现了问题,你可以使用:
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.
相关推荐
最新文章