Yep!
There are a few ways to do this:
Disable Preloading on an Asset
In your XML project, disable preloading for an asset:
<assets path="assets/images" preload="false" />
This means the files will exist at runtime, but will not be preloaded. You cannot use Assets.getBitmapData
and other immediate synchronous access to assets, but can use Assets.loadBitmapData
and other asynchronous methods instead. If you use the cache = true
option (which is the default for these methods), it should be cached to use the get
version later.
Disable Preloading on a Library
All assets go into a “default” library, unless otherwise specified. I believe you can even disable preloading of the library and its assets, but be aware that until you have loaded a library, you will need even be able to Assets.loadBitmapData
for those assets, as the system will not even know the paths and asset IDs exist yet.
<library name="default" preload="false" />
To load at runtime, you could use something like the following:
Assets.loadLibrary ("default").onComplete (function (library) {
var bitmapData = library.getBitmapData ("image.png");
// or
var bitmapData = Assets.getBitmapData ("default:image.png");
// or
var bitmapData = Assets.getBitmapData ("image.png");
// "default:" prefix is implied, if no library prefix is included
});
Using Additional Asset Libraries
You can easily add assets to libraries other than the “default” library. These are not preloaded by default, unless you add <library name="" preload="true" />
<assets path="assets/other" library="stuff" />
If the asset library is not preloaded automatically, you can use Assets.loadLibrary
as above. You can also Assets.unloadLibrary
when you are doing using those resources