actionscript 3 - How to display ping information of a server on the stage in AS3 -


so have code ping server, traces information. want change that, , use dynamic text display ping information on stage. how that? here 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(); } 

it worked, made text box on stage called textbox, , added code end.

var ldr:urlloader = new urlloader(); ldr.addeventlistener(httpstatusevent.http_status, ldrstatus);  var url:string = "http://google.com.net"; var limit:int = 10;  var time_start:number; var time_stop:number; var times:int;  ping();  function ping():void {     trace("pinging", url);      times = 1;     dotheping(); }  function dotheping():void {     time_start = gettimer();     ldr.load(new urlrequest(url)); }  function ldrstatus(evt:*):void {     if(evt.status == 200)     {         time_stop = gettimer();         textbox.text = string("got response in", time_stop - time_start, "ms");     }   } 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -