haxe

how to write a generic compare function in Haxe (haxe3)

感情迁移 提交于 2019-12-04 14:31:39
I am trying to write a generic compare function (like the c strcmp) in Haxe3 for a template type A, assuming that this template type has a less-than-or-equal-to operator "<=". I saw in the Haxe3 documentation ( http://haxe.org/manual/haxe3/features ) that you can do a similar job if you want to assume that a template type has the new function: @:generic static function foo<T:{function new(s:String):Void;}>(t:T) { trace(Type.typeof(t)); // TClass([class String]) / TClass([class Template]) return new T("foo"); } So, I tried the same technique with a "le" function: class Main { @:generic static

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

与世无争的帅哥 提交于 2019-12-04 14:29:51
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? 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 scripts to usage in an AS3 project. Check it out: https://github.com/jcward/HaxeSWCExample Update: Note

Import Haxe modules into a node.js script

不打扰是莪最后的温柔 提交于 2019-12-04 10:03:56
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 } Consider this //Haxenode.hx class Haxenode { @:expose("hello") public static function hello(){ return "hello"; } } @:expose("hello") part is to put something in module.exports . Now launch

How to create iOS- & OSX- library from Haxe and use it in native application?

夙愿已清 提交于 2019-12-04 08:39:38
问题 I have an crossplatform implementation of own protocol, data-structures and logic written on Haxe. How I can build and use it in my enterprise-application (with native UI) for iOS and OSX? 回答1: How to create iOS- / OSX- library from Haxe and use it in native application Actuality: 12.2014; HXCPP-ver.: 3.1.39 ~ git . Dependency: hxcpp 1. Haxe -> Library Create a new Haxe-project with main class named HxModule . src/HxModule.hx class HxModule { public static function main() { Sys.println('Hello

How to exit Haxe/OpenFL program?

这一生的挚爱 提交于 2019-12-04 04:05:11
I am making a game using Haxe, OpenFL (Formerly NME) and HaxeFlixel. However, problem is, I can't seem to find a good way to make a Flixel button that will shutdown the game when pressed. I was planning to make a "quit" button on the main menu. Is there any simple method to do so or is it impossible? It depends on the compilation target: I'm going to assume you're compiling to CPP (Windows EXE). In which case you should just be able to use the following: import flash.system.System; // Or nme.system.System if you're using NME ... // in your FlxButton callback: System.exit(0); I can't test right

Haxe for javascript without global namespace pollution?

廉价感情. 提交于 2019-12-03 02:58:19
This question only applies to Haxe version < 2.10 I've known about haxe for a while, but never really played with it until yesterday. Being curious, I decided to port showdown.js , a javascript port of markdown.pl , to haxe. This was pretty straightforward, and the javascript it generates seems to run fine ( edit: If you want to see it in action, check it out here ). However, I noticed that the generated code dumps a ton of stuff in the global namespace... and what's worse, it does it by assigning values to undeclared identifiers without using the var keyword, so they're global even if you

How to create iOS- & OSX- library from Haxe and use it in native application?

纵饮孤独 提交于 2019-12-03 01:33:06
I have an crossplatform implementation of own protocol, data-structures and logic written on Haxe. How I can build and use it in my enterprise-application (with native UI) for iOS and OSX? Alexander Ko How to create iOS- / OSX- library from Haxe and use it in native application Actuality: 12.2014; HXCPP-ver.: 3.1.39 ~ git . Dependency: hxcpp 1. Haxe -> Library Create a new Haxe-project with main class named HxModule . src/HxModule.hx class HxModule { public static function main() { Sys.println('Hello from HxModule: "${test()}"'); } @:headerCode public static function test():Int { return 101; }

How Do I Navigate / Update The Haxe SDK Inside of FDT?

假如想象 提交于 2019-12-02 19:03:02
问题 On OSX, FDT has the Haxe SDK here: /Applications/FDT 5.app/Contents/FDT5/haxe/haxe-2.09-osx Because this is inside of a OSX package, I can't navigate to it. How to I either: Select it in the preferences. Update it. 回答1: You can either: Manually Copy / Paste the path. Here is an example: /Applications/FDT 5.app/Contents/FDT5/haxe/haxe-2.09-osx Update / replace the SDK via the find by going to 'Show Package Contents' 来源: https://stackoverflow.com/questions/10939596/how-do-i-navigate-update-the

Actionscript 3 vs Haxe: Which to chose for new Flash project?

徘徊边缘 提交于 2019-12-02 17:09:37
I am in the planning stages of a new Flash game project and was wondering which language would be better to use? I already have a strong understanding of Actionscript 3, and have not worked with Haxe yet, but I have read the language reference docs and it seems that Haxe has some of the features from my other favorite languages, C# and Ruby. So my question has two parts: 1) Can Haxe interop with flash components (swc files)? Like for instance if i use the Flash IDE to skin some controls, can i import those controls and use them in Haxe? 2) Are there any performance benefits to the Haxe

How Do I Navigate / Update The Haxe SDK Inside of FDT?

纵饮孤独 提交于 2019-12-02 11:33:17
On OSX, FDT has the Haxe SDK here: /Applications/FDT 5.app/Contents/FDT5/haxe/haxe-2.09-osx Because this is inside of a OSX package, I can't navigate to it. How to I either: Select it in the preferences. Update it. You can either: Manually Copy / Paste the path. Here is an example: /Applications/FDT 5.app/Contents/FDT5/haxe/haxe-2.09-osx Update / replace the SDK via the find by going to 'Show Package Contents' 来源: https://stackoverflow.com/questions/10939596/how-do-i-navigate-update-the-haxe-sdk-inside-of-fdt