So the CPP target is implemented via lime.system.Sytem, but I actually need the AIR target support as well. Due to lack of time and cross-platform video support.
So for now I treat flash build the same as an air build, I do however define an ‘air’ compiler flag as well. I think having the extern works pretty well. We should look at adding it into the System class under to provide the top level directories one commonly needs. Once you have the native path, it’s easy to the standard haxe pathing techniques to get where you want to go.
Unfortunately you would need to use reflection to see whether the ‘flash.filesystem.File’ class is present in the application domain. However, I think it’s safe to assume that developers generally understand when a local file system is available and when it isn’t. I’ll be happy without the check to save on overhead. Devs trying to reference the file system on an unsupported target will simply get an error and (hopefully) understand why.
In the Flash backend code (FlashApplication, for example) we perform a check in order to determine if we are running in AIR. Then subsequent code can check this boolean in order to return null or a real value for APIs in Lime like this. Another idea would be to use Reflection within the call itself, but it could run slower that way
At one time, the tools had built-in AIR support. I believe you would use openfl test ios -air, or something like that, in order to enable it.
I’ve received feedback that this was confusing – that it’s easier to think OpenFL and AIR as two separate things, and I was concerned about the support stagnating and getting broken with some further release of AIR, and causing maintenance headaches.
However, if this is something you’re interested in and would really help your workflow, this could be revisited
var isAIR : Bool = ApplicationDomain.currentDomain.hasDefinition("flash.filesystem.File");
Regarding the air flag, not sure, I’m trying with all my might to get away from using flash. Unfortunately with this case yet again I need to use it. I’ve written a bash script which is pretty comprehensive to compile everything I need. The project I’m working at the moment is a complex html5 website which the client wants as an app as well. I’ve done this before with Flash, but much rather prefer writing complex websites in HaXe/OpenFL. So to keep things cheap I need to get to a solution in the quickest possible way.
My bash script supports:
OpenFL -> HTML5
OpenFL -> HTML5 -> PhoneGap -> Android | iOS
OpenFL -> Flash -> AIR -> Android | iOS
OpenFL -> Android | iOS | neko
After all these various attempts at getting the best outcome, AIR remained the quickest way. Unfortunately.
Problems AIR solve as of now:
APK Expansion Files
Cross-platform Video
Cross-platform Web View (required for some sub content overlays)
I’d love to see better AIR support in Lime, where appropriate. I think it’s a simple place for us to add the abstraction. Inline reflection (like if (ApplicationDomain.currentDomain.hasDefinition("flash.filesystem.File")) { // do AIR stuff } is a quick fix that should help. One way or another, I’d be happy to see it
That’s helpful to see a list, I’d like to see those supported in the future as well
Great! It should be in now, I decided to do Capabilities.playerType == "Desktop", I think this should probably perform just as well, and we don’t have to add an additional check.