[haXe] best strategy to port an existing js library
Franco Ponticelli
franco.ponticelli at gmail.com
Fri Dec 7 17:10:16 CET 2007
Yes, I think you are correct. The only two options are depicted in the
example below... any other idea?
// js library
function niceAlert(txt) {
alert("### " + txt + " ###");
}
// haxe code
class Main {
public static function main() {
Main.msg("hello to you");
Main.msg2("goodbye");
}
public static var msg : String -> Void = untyped niceAlert;
public static function msg2(s : String) {
untyped niceAlert(s);
}
}
Franco.
On Dec 7, 2007 3:42 PM, Ian <bcposn802 at sneakemail.com> wrote:
> 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
> >
> >
>
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.motion-twin.com/pipermail/haxe/attachments/20071207/456144ae/attachment.htm
More information about the Haxe
mailing list