HaxeBridges – Inter-platform coding library

HaxeBridges is a library which allows a single project to be compiled into separate parts, and for separate platforms.
This is useful for many situations, including when multi-threading, client/server, etc.

The idea is that your main application should be able to naturally use objects which will be published via a different platform/compile.

The example included in the repository now is a simple example of creating a worker thread (flash only for the moment).

In the main class:

1
2
3
4
 var obj = new ObjectInsideWorker();
 obj.nonStaticMethod(function(result){
    trace("Worker result: "+result);
 });

And the class which gets compiled into the worker:

1
2
3
4
5
6
7
8
9
10
package;
class ObjectInsideWorker{
 
 public function new(){
 }

 public function nonStaticMethod():String{
    return "nonStaticMethod: "+Std.string(Math.round(Math.random() * 1000));
 }
}

Then all that’s required is a compiler argument to get things working:

1
--macro Bridge.add('ObjectInsideWorker', 'Worker')

(first argument is a comma separated list of classes to be included in the worker)

More examples and bridge-types to come.
Check out the repository here.

2 Comments

  1. Hey! not related to this post, but thought i’d put it out there and thankyou for the work you’ve done with the exporting from flash to animated svg, although i didn’t get a chance to use this professionally i found it a very useful tool. I eagerly anticipate flash cc 2014’s ability to natively export svg, and hope they intend to have this export animated versions later on. Again, thanks for your work on this and i’m sure it’s really appreciated by those who’ve been able to use it to date.

    cheers,

    Nick

    • Thanks Nick.

      I too hope Adobe chooses to add animation to their new SVG export, although I don’t have much hope, the big companies seem to think of SMIL as a legacy technology. I’m not sure that I agree. While it won’t be useful on desktop until Firefox and IE make some big changes, on mobile it is now completely viable (because of the dominance of Webkit browsers). Because of mobile’s growing range of pixel densities, it is really one of the only practical ways to do do clean looking vector animations for mobile.

Leave a Reply

Your email address will not be published.

*

© 2017 Thomas Byrne

Theme by Anders NorenUp ↑