Skip to main content
gegera12438347
New Participant
January 14, 2015
Question

Adobe Air AS3 URLRequest Delay

  • January 14, 2015
  • 2 replies
  • 1150 views

Hi,

I want to make a request to read a url from my apk exported from .fla. The problem is in the first installation, then the request it takes 6 seconds. I do not know what's causing. I open the application 2nd time and request is executed in a second successful.

I attached files and screens here: https://app.box.com/s/unue6ebsgpmkk7jb7yuc

To reproduce the problem you need to uninstall the application and install->run again. Only on the first run is observed the problem.

I will be grateful if someone help me

MyConf:

Air sdk: 16

Flash CC:  14.1.0.96 ( windows 7 64 )

Thanks!

--------------------------------------------------------------

import flash.utils.Timer;

import flash.events.Event;

import flash.events.TimerEvent;

import flash.events.IOErrorEvent;

import flash.net.URLLoader;

import flash.net.URLRequest;

var global_status:String = "none";

var global_magic_event:int = 0;

var text2screen: TextField = new TextField();

text2screen.x = 10;

text2screen.y = 450;

text2screen.width = 300;

text2screen.height = 100;

text2screen.wordWrap = true;

text2screen.border = true;

text2screen.textColor = 0xffffff;

text2screen.backgroundColor = 0x000000;

text2screen.background = true;

text2screen.text = global_status;

addChild(text2screen);

var xloader: URLLoader = new URLLoader();

var url: String = "http://pastebin.com/raw.php?i=TBwVdkFY&rnd="+randomRange(111,99999);

trace(url);

var request: URLRequest = new URLRequest(url);

try {

  xloader.load(request);

  xloader.addEventListener(Event.COMPLETE, processData);

  xloader.addEventListener(IOErrorEvent.IO_ERROR, errorData);

} catch (e: Error) {

  trace("error!!");

  global_status = "err #1";

}

function processData(e:Event):void{

  trace("Loading Completed");

  global_status = "success "+xloader.data.substr(0,250);

}

function errorData(e: Event = null) {

  trace("Loading fail!");

  global_status = "err #2";

}

// debug screen

var timer_start: Timer = new Timer(1000, 1000);

timer_start.addEventListener(TimerEvent.TIMER, showlog);

timer_start.start();

function showlog(e: TimerEvent): void {

  // catch the second where is success

  if( global_magic_event==0 && global_status!="none" ) { global_magic_event = e.currentTarget.currentCount; }

  text2screen.text = "#" + (e.currentTarget.currentCount*e.currentTarget.delay)/1000 + " second | status ["+global_magic_event+"]: "+global_status;

}

function randomRange(minNum:Number, maxNum:Number):Number  {

    return (Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum);

}

This topic has been closed for replies.

2 replies

gegera12438347
New Participant
January 15, 2015

first run - scout screen.

sveni65417610
New Participant
January 24, 2015

Same here...

Dear Adobe guys, PLEASE TAKE A LOOK INTO THIS ISSUE. Lots of Flash assets are broken now (and the problems arose upon recent uptade of Flash Player). Users exit all the games online because they think that 'flash hangs up', while it just waits to close the TCP connection.

THIS IS A CRITICAL BUG!

sveni65417610
New Participant
January 26, 2015

Huh, Adobe, any progress here?

We were able to speed up the process of closing URLLoaders by force closing them from the serve side. But from what I hear in the 'field', the whole industry of online gaming is just down for last few days.

You know, I'm just a manager of AS3 developers and my opinion means nothing, but I hope you'd find new jobs before the big players realize what is going on...

Ned Murphy
Brainiac
January 14, 2015

What is the size of the file that you are loading?  It might be a case where the first time you are actually waiting for the loading to finish whereas the second time you are loading from the cache.

gegera12438347
New Participant
January 15, 2015

Hi,

Is a small txt file ( 2.55 KB ), and i make the request with a random parameter ( &rnd ) to be uniq for each request.

var url: String = "http://pastebin.com/raw.php?i=TBwVdkFY&rnd="+randomRange(111,99999);

I tried on multiple servers, different files, various sizes, with cache, without cache ... the problem is not remote . ( is not a cache problem )

I tried on multiple .fla ... the problem is not on current .fla .. is a global problem.

I added a v2_fla folder (  https://app.box.com/s/unue6ebsgpmkk7jb7yuc ) where i implemented a complete debug.

i added this events:

    xloader.addEventListener(Event.COMPLETE, completeHandler);

    xloader.addEventListener(Event.OPEN, openHandler);

    xloader.addEventListener(ErrorEvent.ERROR, onError)

    xloader.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError);

    xloader.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);

    xloader.addEventListener(ProgressEvent.PROGRESS, progressHandler);

    xloader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);

    xloader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);

    xloader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);

and i tested in adobe_flash_player_14, air_desktop and air_16_for_android and i recorded the time when each event is executed

adobe_flash_player_14: 0 seconds

air_16_desktop: 0 seconds

air_16_for_android_first_run: 5 seconds

air_16_for_android_second_run: 0 seconds

I noticed that Event.OPEN is executed at second 5. why ?

this is a simple script and this delay is a big problem for me. maybe it is a bug air. can someone clarify me? I struggled with this problem for several days.

Thanks!