External JS library with lower case class name

95 views
Skip to first unread message

Jason Kringen

unread,
Mar 13, 2014, 5:52:39 PM3/13/14
to haxe...@googlegroups.com
Hi,

I'm having some trouble figuring out how to interface with an external javascript library. I'm developing in haxe, targeting JavaScript, and running the application on a Smart TV. Some of the JavaScript API methods for the TV (that are built into the TV framework and the source is not available) look like this:

sf.core.exit()
sf.core.getEnvValue(key)
sf.core.loadCSS(files)
etc...

How do I do about calling these methods from Haxe? I tried defining an "extern" class for this, but quickly realized that that may not work. I'd love to be able to define extern classes for all of these different API that exist (so I can have nice code completion in Haxe), but I'm not sure how to do it. Would using the "untyped" method work for something like this?

Anyways, thanks for any help, I'm a bit lost on how to approach this one yet.

-Jason Kringen

Nicolas Cannasse

unread,
Mar 14, 2014, 3:43:25 AM3/14/14
to haxe...@googlegroups.com
Le 13/03/2014 22:52, Jason Kringen a écrit :
> Hi,
>
> I'm having some trouble figuring out how to interface with an external
> javascript library. I'm developing in haxe, targeting JavaScript, and
> running the application on a Smart TV. Some of the JavaScript API
> methods for the TV (that are built into the TV framework and the source
> is not available) look like this:
>
> sf.core.exit()
> sf.core.getEnvValue(key)
> sf.core.loadCSS(files)
> etc...
>
> How do I do about calling these methods from Haxe? I tried defining an
> "extern" class for this, but quickly realized that that may not work.
> I'd love to be able to define extern classes for all of these different
> API that exist (so I can have nice code completion in Haxe), but I'm not
> sure how to do it. Would using the "untyped" method work for something
> like this?

You can use

@:native("sf.core") class Core {
....
}

Best,
Nicolas

Jason Kringen

unread,
Mar 14, 2014, 10:53:59 AM3/14/14
to haxe...@googlegroups.com
Awesome, I totally missed that one on the Haxe Tips & Tricks page. Worked like a charm, thanks!!
Reply all
Reply to author
Forward
0 new messages