I’m building an app with Flex 4.6 and AIR. It will be published on Android and iPhone but for now I’m testing on an Android device.
I’ve got the basic flow working with different screens and even a flash component.
However, when switching between screens, all of my s:Image objects take a long time to load, even when deployed to an actual device. By long time I only mean about a half a second. This normally wouldn’t be so bad, but the text on the screen shows up immediately, while all of the images remain white for half a second and then they load.
Is this just an AIR/Flex thing? Has anyone else run in to this, hopefully with a solution?
Images tend to load quicker if you embed them in the Flex App. More info on that here. The code behind this would look like this:
Then you can use that class like this:
[code copied from docs]
If you need to use the same image multiple times, you should look into using the BitMapImage class; and cloning the bitMapData of the first image. Here is a quick utility class I “Borrowed and modified” for getting the BitMapData from a sprite, and vice versa. [The Flex Image class class extends sprite, so you should be able to send an image in as the input]
Once you have the BitMapData you can call clone to get a copy of it and create multiple instances of the same image. [Do some research into blitting; a technique used by game developers]. The Spark Image tag will also accept BitMapData as the source.