I’m working on trying to get Haxe/OpenFL running for a project that targets AIR. I’m fairly new to Haxe, so this might be obvious.
So far, I’ve been able to successfully use some AIR APIs/classes in a project that targets AIR, but the IDE I’m using (Intellij) doesn’t seem to have access to any AIR externs, so working with AIR APIs is a bit of a chore. What am I missing?
UPDATE: I tried importing haxe/lib/lime/6,4,0/externs/air as a module dependency, and it seems to fix the IDE’s access to the classes, but certain classes (ie, FileStream) now throw objectEncoding errors on compilation.
Okay, I removed the module import, and I can confirm that when I run “openfl test air” the air extern path (/usr/local/lib/haxe/lib/lime/6,4,0/externs/air) shows up in the list.
However, Intellij now doesn’t recognize the AIR class references again, and although some class references compile fine anyway, others cause compilation errors.
For example, when I create the following Main class:
package;
import openfl.display.Sprite;
import flash.filesystem.FileStream;
class Main extends Sprite {
public function new () {
super ();
var fileStream:FileStream = new FileStream();
}
}
…FileStream is flagged by Intellij as an “unresolved symbol”, and testing from the command line gives the following errors:
/usr/local/lib/haxe/lib/lime/6,4,0/externs/air/flash/filesystem/FileStream.hx:3: lines 3-40 : Field objectEncoding has different type than in openfl.utils.IDataOutput
/usr/local/lib/haxe/lib/openfl/8,3,0/src/externs/core/openfl/openfl/utils/IDataOutput.hx:21: characters 8-42 : Interface field is defined here
/usr/local/lib/haxe/lib/lime/6,4,0/externs/air/flash/filesystem/FileStream.hx:3: lines 3-40 : UInt should be openfl.net.ObjectEncoding
/usr/local/lib/haxe/lib/lime/6,4,0/externs/air/flash/filesystem/FileStream.hx:3: lines 3-40 : Field objectEncoding has different type than in openfl.utils.IDataInput
/usr/local/lib/haxe/lib/openfl/8,3,0/src/externs/core/openfl/openfl/utils/IDataInput.hx:29: characters 8-42 : Interface field is defined here
/usr/local/lib/haxe/lib/lime/6,4,0/externs/air/flash/filesystem/FileStream.hx:3: lines 3-40 : UInt should be openfl.net.ObjectEncoding
It sounds like there are some minor issues with the Lime externs that need to be resolved, which don’t appear until runtime, when using certain classes, I guess.
Could you try changing this line to #if openfl openfl.utils.ObjectEncoding #else UInt #end and see if it works?
The Intellij plugin still doesn’t know what to make of FileSystem (I don’t think it’s looking at the AIR externs) but I assume that’s an issue for the plugin developer?