Copy link to clipboard
Copied
Hi,
We have created a Adobe Air application, only we stumble across a delay in handling data. We are loading a XML file (1,8 mb) and process it to flash objects like inputfields etc.
Only on my normal Windows 7 pc it takes 5 sec to load only on a windows server 2013 R2 server its up to 15 sec to process the data. (see screenshot)
Is there someone who has same problem with loading XML data en process it as flash objects?
With best regards,
René
Copy link to clipboard
Copied
your loading should be asynchronous. is it?
if so, the delay will be in your processing. using chunking to allow stage updates during that processing so the user sees no screen freeze, or display a warning about the screen freeze so the user is informed.
Copy link to clipboard
Copied
@kglad yeah my request is a async request.
What do you exactly mean by "using chunking to allow stage updates during that processing so the user sees no screen freeze."
Copy link to clipboard
Copied
this is an excerpt from a book i wrote (Flash Game Development: In a Social, Mobile and 3D World)
Loops
There are two significantly different loop types in ActionScript. One type that executes from start to end before any other code executes and before anything updates on stage and one type that does neither of those things.
Loop types that execute from start to end before anything updates on stage include do-loops, for-loops and while loops. They cannot be used to animate objects because no matter what code you use to execute the loop and no matter what you do to (try and) slow it down, it will still execute from start to finish before anything changes on stage. They are appropriately used for rapid execution of code.
There is never a situation when you should intentionally slow these loops. However, there are situations when you might want to break these loops into more than one chunk so the stage can update between each chunk.
For example, if you have a for-loop that takes 10 seconds to execute, your game will appear to freeze for 10 seconds after this loop starts. Nothing will update on stage and nothing will respond to user input. Either you should warn your user before starting that loop or you should break that loop into several smaller chunks that allow visual updates to the user so they do not think your game is broken.
For example, this for-loop that adds odd numbers (and shows the first m odd numbers sum to m*m) freezes my Flash Player for about 9 seconds.
var i:Number;
var n:Number=3000000000;
var s:Number=0;
var startI:Number=1;
var endI:Number=n
var startTime:int=getTimer();
for (i=startI; i<endI; i+=2) {
s+=i;
}
// 9 seconds
trace((getTimer()-startTime)/1000,s,n*n/4,s-n*n/4);
The following technique shows how to break this (and any other for-loop) into chunks that allow the Flash Player to update every second.
var i:Number;
var n:Number=3000000000;
var s:Number=0;
var startTime:int=getTimer();
// This is the number chunks into which the previous for-loop will broken. If the // previous for-loop took about 9 seconds, using 10 chunks means there will be updates // about every 0.9 seconds.
var chunks:int=10;
var startI:Number=1;
var endI:Number=n/chunks;
var t:Timer=new Timer(100,1);
f();
function f(e:Event=null):void {
for (i=startI; i<endI; i+=2) {
s+=i;
}
trace("stage update",startI,endI,s);
if (endI<n) {
t.reset();
t.start();
} else {
trace((getTimer()-startTime)/1000,s,n*n/4,s-n*n/4);
}
startI+=n/chunks;
endI+=n/chunks;
}
Copy link to clipboard
Copied
Thanks for explaining, we are going to look into this.
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now