plicatibu Posted November 30, 2013 Share Posted November 30, 2013 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 Quote Link to comment Share on other sites More sharing options...
lordkryss Posted December 2, 2013 Share Posted December 2, 2013 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? ThanksHi, 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 plicatibu 1 Quote Link to comment Share on other sites More sharing options...
plicatibu Posted December 2, 2013 Author Share Posted December 2, 2013 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? Quote Link to comment Share on other sites More sharing options...
andrew Posted December 17, 2013 Share Posted December 17, 2013 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? Quote Link to comment Share on other sites More sharing options...
plicatibu Posted December 18, 2013 Author Share Posted December 18, 2013 @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:3324In Chrome I saw the following error message in console:Uncaught TypeError: Cannot read property 'currentCount' of null Game.js:3324Once 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. Quote Link to comment Share on other sites More sharing options...
andrew Posted December 18, 2013 Share Posted December 18, 2013 @plicatibuIn this case target and curentTarget should be the same.And e.target.currentCount works fine on js, you don't need cast (var e:TimerEvent = cast (event, TimerEvent);).So you could use it. plicatibu 1 Quote Link to comment Share on other sites More sharing options...
plicatibu Posted December 18, 2013 Author Share Posted December 18, 2013 Andrew, thank you a lot for telling me that. It worked on HTML5 too. Regards. @plicatibuIn this case target and curentTarget should be the same.And e.target.currentCount works fine on js, you don't need cast (var e:TimerEvent = cast (event, TimerEvent);).So you could use it. Quote Link to comment Share on other sites More sharing options...
andrew Posted December 18, 2013 Share Posted December 18, 2013 You're welcome )Although undefined currentTarget for Timer only on html5 it's probably bug in OpenFL. Quote Link to comment Share on other sites More sharing options...
solariz Posted August 14, 2018 Share Posted August 14, 2018 Thank you very much. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.