Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to send data away immediately by URLLoader?

New Here ,
May 19, 2013 May 19, 2013

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.

TOPICS
ActionScript
474
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 20, 2013 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 21, 2013 May 21, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 22, 2013 May 22, 2013
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines