I have some images that are being loaded at runtime and store them as BitmapData instances. Since most of my old libraries make use of openfl.Assets.getBitmapData() to get images, I thought it would be neat to just add the BitmapData objects to the Assets class’ cache and make them accessible that way. So I’m using Assets.cache.setBitmapData() to put images into the cache. The problem is that retreiving the images only works directly from the cache:
Assets.getBitmapData(id) // returns null
Assets.cache.getBitmapData(id) // returns the BitmapData I stored earlier
Then I looked at the source of Assets.getBitmapData and saw it checks 2 compiler flags like this:
#if (tools && !display)
// Imagine the actual code that would return the BitmapData from the cache here.
#end
return null;
To test it I put some traces in there and it turns out the inside of that conditional compilation if statement thingy never gets executed. That’s why it returns null. What are those “tools” and “display” compiler flags? I tried googling them but they’re such generic words it’s been hard to come up with any useful results. “display” is listed in the haxe documentation but all it says is “Activated during completion”. Not sure what that means. “tools” isn’t listed there so I assume it’s defined by openfl or lime?