Skip to main content
Participant
May 20, 2013
Question

How to send data away immediately by URLLoader?

  • May 20, 2013
  • 1 reply
  • 503 views

Hi,

Grateful for your reading first.

This is my code:

private function send( pkt:ByteArray )

{

     var int count = 0;

     var request:URLRequest = new URLRequest( ... );

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

     request.contentType = URLLoaderDataFormat.BINARY;

     request.method = URLRequestMethod.POST;

     loader.addEventListener(Event.COMPLETE, loader_complete);

     loader.dataFormat = URLLoaderDataFormat.BINARY;

     request.data = pkt;

     loader.load( request );

     //to pause the execution

     while( count < 100000000 );

}

The COMPLETE event will not be dispatched before the last while loop ended.

That's to say after URLLoader.load( URLRequest ), the loader will not sent data away immediately( no delay )?

Cause a number of loader.load(request) commands need to be executed continuely and in order, I need to send data away without delay for each load command in order.

How to solve it?

Thanks.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
May 20, 2013

while, for and do loops cannot be used to pause execution.  they execute from start to finish before anything else occurs including display updates.

to remedy, use several for-loops to "chunk" your data handling.

Participant
May 22, 2013

Many thanks to your answer. But it has no relation to my question. I just want to POST a byteArray without delay.

kglad
Community Expert
Community Expert
May 22, 2013

then what's the point of your attempt to use a while-loop?