haxe

Haxe - Create a C++ Stand-alone executable

岁酱吖の 提交于 2019-12-07 15:41:17
问题 I have written a haxe program that tries to communicate with a remote server. I was able to compile to the C++ target successfully. The executable runs just fine on my system. However, when I try to run the same on another windows box, it fails with the following error Error: Could not load module std@socket_init__0 I then installed haxe and hxcpp which worked like a charm. I was able to run the exe. I understand now that there is dependency on hxcpp. That still did not solve my problem as I

Haxe Custom Metadata to Macro Call

早过忘川 提交于 2019-12-07 11:45:10
问题 Let's say that I've created a build macro that can be used like so @:build(macros.SampleMacro.build("arg")) class Main {} Is it possible to convert it into a custom, shorthand metadata? @:samplemacro("arg") class Main {} Any documentation on this? 回答1: I'm not sure that's possible, but you can make use of the fact that @:autoBuild() metadata works on interfaces. This is often used for "marker interfaces" like this: class Main implements ISampleMacro {} @:autoBuild(macros.SampleMacro.build(

Use Haxe API classes explicitly

≡放荡痞女 提交于 2019-12-07 05:54:17
问题 I use Haxe targeting Javascript. I have a package (defined as an extern), " phaser ", that contains a Math class along with many others. I use import phaser.*; at the beginning of my files because I use many classes from this package and I don't want to prefix them all with phaser. . I would like to use the Math class from Haxe API, but if I try to use it (e.g Math.random() ), the compiler thinks I want to use phaser.Math and tells me there is no such function in it. Can I explicitly write

FlashDevelop/OpenFL: How to set default target to neko

二次信任 提交于 2019-12-06 16:48:51
I am trying to write some cross-language code with Haxe/OpenFL and compile it using FalshDevelop. But I get an error as soon as I use the basic Sys.print function. A minimal example is as follows: package; import flash.display.Sprite; class Graphic extends Sprite { public function new () { super (); } static function main() { //used in standalone swf project Sys.print("Hi"); } } It turns out that the default compile command of FlashDevelop is something like: haxelib run openfl build project.xml flash ,which gives an error on Sys.print : Graphic.hx:xx: characters 2-11 : Accessing this field

Ensure that a Haxe program will run on all platforms

时间秒杀一切 提交于 2019-12-06 11:23:29
问题 I plan to write Haxe libraries in a subset of Haxe that will compile to every Haxe target language. Is there any way to verify that a Haxe program will compile to all target languages, and is it possible to do this without manually testing the compiled code on each target platform? For example, is there a way to ensure that the following code is valid on every target platform, without testing it manually on every single platform? class Test { static function main(){ trace("How can I check to

Duplicate image with Haxe

ⅰ亾dé卋堺 提交于 2019-12-06 10:55:08
问题 My goal is to make a wide map using only one square image. Using actionscript 3 the solution is to simply make new Bitmap from the Loader: var loader:Loader = new Loader(); loader.load(new URLRequest("xyz.png")); this.addChild(loader); var duplicationBitmap:Bitmap = new Bitmap(Bitmap(loader.content).bitmapData); Unluckily, Haxe API doesn't allow to do that. I can't get bitmapData from loader content… Anyone has a clue? Thanks. 回答1: The API is the very same, so I guess the problem is how you

Using Haxe macro for conditional compilation, instead of #if #end

点点圈 提交于 2019-12-06 09:20:56
Suppose we have a Local class with : class Local { static inline public var logLevel:Int = 3; } And some functions : Tool.debug(s:String) // compiled if logLevel >= 0 Tool.moreinfo(s:String)// compiled if logLevel >= 1 Tool.info(s:String) // compiled if logLevel >= 2 Tool.trace(s:String) // compiled if logLevel >= 3 Tool.warn(s:String) // compiled if logLevel >= 4 Tool.err(s:String) // compiled if logLevel >= 5 We can achieve this using -D and some #if in the code. However that implies modifying the hxml file all the time. Even if it's just for one value, this isn't ideal for me as all my

Can we use compiled Haxe swf's swc's in Actionscript as normal libs?

青春壹個敷衍的年華 提交于 2019-12-06 07:40:44
问题 Can we use compiled Haxe swf's swc's in Actionscript as normal libs? I have a swf compiled from haxe code (I can try to compile it into something else SWC for ex) I want to use it as lib in AS3. Is it possible? If yes how to do it? 回答1: Yes, you can, the performance increase is worth it, and it's surprisingly easy! I got 3-4X speed-up on both a simple sum-of-primes algorithm and a complex 2D bin packing algorithm. I've posted an entire example project on github -- from Haxe source and compile

Import Haxe modules into a node.js script

北战南征 提交于 2019-12-06 06:15:58
问题 Using node.js and Haxe, is there any way to write a function that generates a node.js modules from a Haxe file, and then returns the generated module? I'm started writing node.js modules using Haxe, and I need a way to import the modules more easily. function requireHaxe(variableToRequire, haxeFileLocation){ //generate a JavaScript module from the Haxe file, and then return the generated JavaScript module } 回答1: Consider this //Haxenode.hx class Haxenode { @:expose("hello") public static

Using objects as Map keys in Haxe

时光怂恿深爱的人放手 提交于 2019-12-06 00:59:19
I'm trying to make a Map with an object as a key. The problem is, that when I try to get elements from this map, I always get null . It's because I'm not providing the exact same reference as the key was. I'm providing an object with the same values , so the reference is different. Is there any way to solve that? Can I make it use some kind of equals() function? class PointInt { public var x:Int; public var y:Int; ... } var map = new Map<PointInt, Hex>(); var a = new PointInt(1, 1); var b = new PointInt(1, 1); var hex_a = new Hex(); map[a] = hex_a; var hex_b = map[b]; /// hex_b == null now