[haXe] best strategy to port an existing js library

Ian bcposn802 at sneakemail.com
Fri Dec 7 16:42:53 CET 2007


how would you call a javascript function from haXe?  It seems like 
extern only works with classes.
I guess I could wrap the javascript functions in a javascript class.

-ianxm

Franco Ponticelli franco.ponticelli-at-gmail.com |haxe| wrote:
> There is no loader and I doubt you need one since you can include your 
> JS library just before the haXe generated file.
> About wrapping you can use both extern or typedef depending on what 
> you are implementing.
> In your case the extern could be the right solution.
>
> extern HelloClass {
>   public function new() : Void;
>   public function showText() : String;
> }
>
> Pay attention to the case of fields that in haXe must start with a 
> lower case letter. This can be origin to incompabilities.
>
> Regards,
> Franco.
>
> On Dec 7, 2007 11:00 AM, picnic <bitvolt at gmail.com 
> <mailto:bitvolt at gmail.com>> wrote:
>
>     hi
>     what is best strategy to port an existing js library? How is
>     encapsulation done, e.g.  for an js class in a separate file:
>
>     -------------HelloClass.js------------------
>     function HelloClass(){
>        var m_text = "Hello World";
>        this.ShowText = DisplayText;
>       function DisplayText(){
>            alert( m_text );
>            return;}}
>     --------------------------------------------------
>
>     i guess there should be some kind of a loader function in haxe.js
>
>     thanks
>     picnic
>
>     --
>     haXe - an open source web programming language
>     http://haxe.org
>
>





More information about the Haxe mailing list