actionscript 3代码在本地运行良好但不在我的服务器中

时间:2016-01-11 01:33:50

标签: javascript actionscript-3 actionscript

我在flash中嵌入了actionscript3中的一段代码来测量ping。 当我通过本地html执行它时,它运行良好。 但是当我通过我的服务器执行它时,第二个http帖子不会被执行,除此之外,一切都很好。

import JSON;
var myRequest:URLRequest = new URLRequest("xxxxxxx");
var myLoader = new URLLoader();
myLoader.addEventListener(Event.COMPLETE, onload);
myLoader.load(myRequest);

function onload(evt:Event):void
{
var obj:Object = JSON.parse(myLoader.data);
var ldr:URLLoader = new URLLoader();
ldr.addEventListener(Event.COMPLETE, ldrStatus);

var url:String = obj.url; 
var src:String;
var limit:int = obj.measurementTimes;

var time_start:Number;
var time_stop:Number;
var i:int = 0;
var TimesArray:Array = new Array();

ping();

function ping():void
    {
     i = 0;
     postToServer(JSON.stringify(obj));////THIS ONE WORKS WELL////////////////////////
     doThePing();
    }

function postToServer(content:String)
  {
      var url:String = "xxxxx";
      var Postrequest:URLRequest = new URLRequest(url);
      Postrequest.method = URLRequestMethod.POST;

      var requestVars:URLVariables = new URLVariables();
      requestVars.myobj = content;
      Postrequest.data = requestVars;

      var loader:URLLoader = new URLLoader();
      loader.load(Postrequest);

  }


function doThePing():void
 {
   src = url + '?random-no-cache=' + Math.floor((1 + Math.random()) * 0x10000).toString(16);
   time_start = getTimer();
   ldr.load(new URLRequest(src));
 }

function ldrStatus(evt:Event):void
{
    time_stop = getTimer();
    TimesArray[i] = time_stop - time_start;
      obj.task[0].value = obj.task[0].value + TimesArray[i]+ " ";
    trace("got response in", obj.task[0].value, "ms");

     obj.task[0].IsFinished = true;
     var objJson:String = JSON.stringify(obj);
     postToServer(objJson);////////THIS ONE DOES NOT BE EXECUTED WHEN ON THE SERVER////////////////////////////////////////////////////////

}

}

0 个答案:

没有答案