0

I'm working on a project and have come to a bit of an issue due to a limitation of the backend I'm using for me program.

First of all my question is "can I measure the data size of text through URLLoader?".

I'm making an app that is required to receive and send a fair bit of data, but the back end I'm using has limited to me only being able to send 1024 at a time.

The backend is called 'Scoreoid', it's really good for games and user management and such, but i'm using it in a bit of a different way.

All the a side, my issue is, I'm sending data through an array, and I can easily enough break up the array and send it in multiple transactions... but is there a way I can measure the size of the data?

That way I could determine how much of the array I can send at a time.

Here is the code they provide:

function getGame():void 
{

var url:String = "API URL";
var request:URLRequest = new URLRequest(url);
var requestVars:URLVariables = new URLVariables();
request.data = requestVars;
requestVars.api_key = "YOUR API KEY";
requestVars.game_id = "YOUR GAME ID";
requestVars.response ="XML"
    requestVars.username ="Players Username"
    requestVars.key ="Your Key"
    requestVars.value ="Key Value"
    request.method = URLRequestMethod.POST;

var urlLoader:URLLoader = new URLLoader();
    urlLoader = new URLLoader();
    urlLoader.dataFormat = URLLoaderDataFormat.TEXT;
    urlLoader.addEventListener(Event.COMPLETE, loaderCompleteHandler);

    urlLoader.load(request);
}


function loaderCompleteHandler(event:Event):void 
{
trace("responseVars: " + event.target.data);
}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

1

URLLoader class has property bytesTotal. You should be able to determine the size of the data through it.

function loaderCompleteHandler(event:Event):void 
{
    trace("responseVars: " + event.target.data);
    trace("size: " + URLLoader(event.target).bytesTotal);
}
Petr Hrehorovsky
  • 1,153
  • 2
  • 14
  • 16
  • But that only seems to work when receiving data. I'm attempting to send data. Size reports as 0 – Jesse Mount Feb 19 '14 at 23:02
  • I see. I'm sorry, it wasn't clear to me from the description. Anyway in that case I'm afraid that `URLLoader` doesn't provide such method. If I understand correctly, you need to measure data sent through `URLVariables`? – Petr Hrehorovsky Feb 20 '14 at 07:44