plicatibu

Best way to integrate javascript libraries into openfl-html5 projects

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

 

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Yes, that's what I was asking.

 

Thank you very much.

 

May I ask you a help about another question?

 

I'm trying to use Timer / TimerEvent but it's not working when targeting HTML 5 (it works fine on flash).

 

Do you have any idea what can be the problem?

Share this post


Link to post
Share on other sites
May I ask you a help about another question?

 

I'm trying to use Timer / TimerEvent but it's not working when targeting HTML 5 (it works fine on flash).

 

Do you have any idea what can be the problem?

Works fine for me, may be problem not in Timer?

Share this post


Link to post
Share on other sites

@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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.