Skip to main content
Participating Frequently
January 13, 2014
Answered

AIR hangs on iOS when instantiating five 600 line arrays

  • January 13, 2014
  • 1 reply
  • 564 views

Hey guys, not sure how to go about fixing this problem.

In previous versions of air, the compilation time would take literally hours when converting the swf to apk if I had my level data array on the timeline. With AIR 4, the device just hangs when trying to intialize the arrays.

I have my level data organized in various arrays as follows:

var level5Array:Array = [

[10, 1, -34, 443, 12, -15, 0, 0, -0.15, 0.5, 99.9, 8, 0, 0, 0, 0, 0, 0],

[10, 1, -33, 443, 12, -15, 0, 0, -0.15, 0.5, 99.9, 8, 0, 0, 0, 0, 0, 0]

//etc.

];

which in total becomes around 3000 lines of actionscript. When I run this on android, everything is fine, but iOS, both 4th and 5th generation hangs when it gets to the frame this need to be initialized.

Any ideas?

This topic has been closed for replies.
Correct answer User Unknow

How many objects do you have with this array? Just one or more? If just one - could you convert it to private static const? This will save a lot of CPU time.

Also try to make predefined Array from byteArray.

import flash.utils.ByteArray;

var level5Array:Array = [

[10, 1, -34, 443, 12, -15, 0, 0, -0.15, 0.5, 99.9, 8, 0, 0, 0, 0, 0, 0],

[10, 1, -33, 443, 12, -15, 0, 0, -0.15, 0.5, 99.9, 8, 0, 0, 0, 0, 0, 0]

];

var ba : ByteArray = new ByteArray();

ba.writeObject(level5Array);

This will store your LevelArray. Than using FileReference save this file to harddrive as binary file.

In your game just load it and make:

var loadedLevelBytes : ByteArray= new ByteArray();

var loadedLevel : Array = ldr.readObject();

Where loadedLevelBytes is loaded bytes from URLLoader or FileStream or File whatever you use... This can add huge performance. Juse try this.

The main idea it's not to use realtime generation in Air runtime. Released APP must have for example Level.bin file and just second part of code. First one use only during developing process.

1 reply

User Unknow
User UnknowCorrect answer
Legend
January 14, 2014

How many objects do you have with this array? Just one or more? If just one - could you convert it to private static const? This will save a lot of CPU time.

Also try to make predefined Array from byteArray.

import flash.utils.ByteArray;

var level5Array:Array = [

[10, 1, -34, 443, 12, -15, 0, 0, -0.15, 0.5, 99.9, 8, 0, 0, 0, 0, 0, 0],

[10, 1, -33, 443, 12, -15, 0, 0, -0.15, 0.5, 99.9, 8, 0, 0, 0, 0, 0, 0]

];

var ba : ByteArray = new ByteArray();

ba.writeObject(level5Array);

This will store your LevelArray. Than using FileReference save this file to harddrive as binary file.

In your game just load it and make:

var loadedLevelBytes : ByteArray= new ByteArray();

var loadedLevel : Array = ldr.readObject();

Where loadedLevelBytes is loaded bytes from URLLoader or FileStream or File whatever you use... This can add huge performance. Juse try this.

The main idea it's not to use realtime generation in Air runtime. Released APP must have for example Level.bin file and just second part of code. First one use only during developing process.

ExbiaAuthor
Participating Frequently
January 14, 2014

Ah good idea I will try this

Thanks for the help