Jump to content

Best way to integrate javascript libraries into openfl-html5 projects


plicatibu
 Share

Recommended Posts

Hi, guys.

 

You that use openfl-html5 for making games, could please share with me how you integrate 3rd party javascript library (say, Leadbolt, flurry, and so on) ?

 

Do you insert the code while writing the openfl-html5 or do you add the javascript to final code generated by openfl?

 

And why do you take the approach you use?

 

Thanks

 

 

Link to comment
Share on other sites

Hi, guys.

 

You that use openfl-html5 for making games, could please share with me how you integrate 3rd party javascript library (say, Leadbolt, flurry, and so on) ?

 

Do you insert the code while writing the openfl-html5 or do you add the javascript to final code generated by openfl?

 

And why do you take the approach you use?

 

Thanks

Hi, are you asking how to call js functions from haxe?

As far as i know there are 2 ways of doing that, the first is using 

untyped __js__("your js code here");

And the second one is using externs, as I did for clay.io here, you can use https://github.com/jgranick/buildhx to make externs easily

Link to comment
Share on other sites

  • 3 weeks later...

@andrew, I used the following code:

timer = new Timer(1000, timeToMemorize);timer.addEventListener(TimerEvent.TIMER, countDown);timer.addEventListener(TimerEvent.TIMER_COMPLETE, countEnd);timer.start();
private function countDown(event:TimerEvent):Void {        var e:TimerEvent = cast (event, TimerEvent);        trace("e.currentTarget.currentCount = " + e.currentTarget.currentCount);        if (e.currentTarget.currentCount > 2) {            playSound();        }

On Flash it worked fine. On HTML5 an exception was generated.

 

In Firefox console I saw the following error message:

[16:34:37.880] TypeError: e.currentTarget is null @http://maoserver.com/bin/Game.js:3324

In Chrome I saw the following error message in console:

Uncaught TypeError: Cannot read property 'currentCount' of null Game.js:3324

Once I stopped using e.currentTarget. the error vanished.

 

I bypassed this problem using an attribute that I incremented each time the callback was called.

 

Regards.

Link to comment
Share on other sites

  • 4 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...