NME beginner - Problem when targeting Html5 (Timer, Buttons...)

324 views
Skip to first unread message

Julien A

unread,
Jan 4, 2013, 5:06:55 AM1/4/13
to haxe...@googlegroups.com
Hi everyone,

Im starting to use haxe NME and it seems quite wonderful. It works fine when targeting flash but I got many problems with html5.
Maybe you could help me answering a few questions :).

nme.utils.Timer
It is not working well in html5, it only play once or badly ? Is it special way to code an nme timer to make it work in html5 ?
Or should I simply look at Actuate ?

nme.display.SimpleButton
- For callbacks I'm using MouseEvent.CLICK listeners in an as3 way... and it is not working at all :)
- When hovering, the button disapears.
- No hand cursor (is it possible in html5 ?)

nme.text.TextField
I simply don't see my text.


Maybe i should try an external library for UI components. Could you show me one fully compatible when targeting html5 ?

Thanks a lot.




j...@justinfront.net

unread,
Jan 4, 2013, 8:41:21 AM1/4/13
to haxe...@googlegroups.com
Julian

you should try haxe.Timer it seems to work fine is js with or without NME, for instance I use it with some pure haxe js to animate a zebra  ( http://www.justinfront.co.uk/tutorials/javascript_canvas_texture/ )

I never use Button or SimpleButton or the like in flash, I find MovieClip is a more valid approach, I would be inclined to just use a MovieClip in NME html5, or maybe switch between several sprites or bitmaps implementing my own rollover states by changing visible properties.  It's a lot of work for js to emulate flash so you have to maybe approach js target with optimal in mind and not just throw any old flash into NME and expect a good html5 result, you have to code smart.  One approach I have used in Jeash a long time back was to switch bitmapData on rollover it seems quite fast.

Have you looked at Jeash documentation for NME html5, for instance found this link  -  http://haxe.org/com/libs/jeash/embedfont

Best 

Justin


Julien A

unread,
Jan 4, 2013, 8:56:59 AM1/4/13
to haxe...@googlegroups.com
I hoped all nme basic classes were fully compatible with html5. 
But it would have been a little too much magic i suppose :).

Step by step, i'm trying to identify what can work (or not) using my curent as3-coding habits.

I missed that linl, thank you.



Axel Huizinga

unread,
Jan 4, 2013, 10:27:16 AM1/4/13
to haxe...@googlegroups.com
Have you looked at Jeash documentation for NME html5, for instance found this link  -  http://haxe.org/com/libs/jeash/embedfont

Best 

Justin

Regarding the hxswfml tool I found that it doesn't work perfectly in all cases (Museo 400 Font):

see http://paradiseprojects.de/devel/js/cufon_nme.html

the first line was created with cufon's converter
the second was a test with hxswfml and a nme sample project.

btw. just tried to recompile it to get rid of the oval but failed with:

C:\Motion-Twin\Haxe\lib\nme/3,4,3/jeash/display/Stage.hx:259: characters 2-53 : jeash.Event should be jeash.events.Event
C:\Motion-Twin\Haxe\lib\nme/3,4,3/jeash/display/Stage.hx:548: characters 27-48 : jeash.events.Event should be jeash.Event
C:\Motion-Twin\Haxe\lib\nme/3,4,3/jeash/display/Stage.hx:548: characters 27-48 : For function argument 'evt'
C:\Motion-Twin\Haxe\lib\nme/3,4,3/jeash/display/Stage.hx:508: characters 2-14 : This field cannot be accessed since it is not an actual var
C:\Motion-Twin\Haxe\lib\nme/3,4,3/jeash/display/Stage.hx:75: characters 8-60 : Add @:isVar here to enable it
C:\Motion-Twin\Haxe\lib\nme/3,4,3/jeash/display/Stage.hx:513: characters 13-25 : This field cannot be accessed since it is not an actual var
C:\Motion-Twin\Haxe\lib\nme/3,4,3/jeash/display/Stage.hx:75: characters 8-60 : Add @:isVar here to enable it
C:\Motion-Twin\Haxe\lib\nme/3,4,3/jeash/display/Stage.hx:514: characters 3-15 : This field cannot be accessed since it is not an actual var
C:\Motion-Twin\Haxe\lib\nme/3,4,3/jeash/display/Stage.hx:75: characters 8-60 : Add @:isVar here to enable it
C:\Motion-Twin\Haxe\lib\nme/3,4,3/jeash/display/Stage.hx:573: characters 49-66 : This field cannot be accessed since it is not an actual var
C:\Motion-Twin\Haxe\lib\nme/3,4,3/jeash/display/Stage.hx:82: characters 8-86 : Add @:isVar here to enable it
C:\Motion-Twin\Haxe\lib\nme/3,4,3/jeash/display/Stage.hx:580: characters 2-19 : This field cannot be accessed since it is not an actual var
C:\Motion-Twin\Haxe\lib\nme/3,4,3/jeash/display/Stage.hx:82: characters 8-86 : Add @:isVar here to enable it
C:\Motion-Twin\Haxe\lib\nme/3,4,3/jeash/Lib.hx:526: characters 9-14 : Dynamic should be Void
C:\Motion-Twin\Haxe\lib\nme/3,4,3/jeash/net/URLLoader.hx:221: characters 9-38 : Missing return Dynamic

looks like nme is not compatible with my current haxe version (2.11 r5656) or what might be the reason for those errors?

Cordially,
Axel

E-Mail ist virenfrei.
Von AVG überprüft - www.avg.de
Version: 2013.0.2805 / Virendatenbank: 2637/5977 - Ausgabedatum: 21.12.2012
Die Virendatenbank sind veraltet.


j...@justinfront.net

unread,
Jan 4, 2013, 11:19:43 AM1/4/13
to haxe...@googlegroups.com
>
> btw. just tried to recompile it to get rid of the oval but failed
> with:


NME does not normally work with svn haxe.

With the new html5 changes in haxe either use current haxe or forget
using NME until haxe3 comes out. I actually code NME on a PC and
haxe3 js on a mac! Really you should not need the NME for coding JS
it's nice and probably has a lot of optimization built in but at some
stage your going to have to learn about the canvas and dom api's in
javascript, I would say also the same about lots of the JS libraries
they are nice but also useful to do stuff from scratch in haxe js so
you then know what's going on.

Justin

Joshua Granick

unread,
Jan 4, 2013, 5:57:26 PM1/4/13
to haxe...@googlegroups.com
NME 3.5.3 was re-released with minor changes to preserve compatibility
with the most recent Haxe SVN.

Joshua Granick

unread,
Jan 4, 2013, 6:02:57 PM1/4/13
to haxe...@googlegroups.com
Hi Julien!

The C++ targets in NME are quite mature, but I would still call HTML5 "beta"

Would you mind adding a bug report to http://haxenme.atlassian.net?

I have tested haxe.Timer on all targets, but it sounds like there is a problem with the HTML5 nme.utils.Timer. I'd love to address this. In a similar vein, it sounds like there is a bug in the SimpleButton implementation. A similar bug was present in C++ a long time ago... perhaps it hasn't been addressed since the time the HTML5 target was first forked from our C++ target a few years ago.

In order to display text, you need to have the fonts embedded.

Try making sure that a TTF is being included through your NME project file, then in your code, use Assets.getFont ("path/to/font.ttf").fontName when setting your text format. You may also need to set "defaultTextFormat" before writing text, rather than setting the text format afterward.

If you must have runtime text, you can try "htmlText", which I believe uses DOM text rather than rendering to canvas, but I haven't tried that myself.

Thanks!

Axel Huizinga

unread,
Jan 5, 2013, 4:21:57 AM1/5/13
to haxe...@googlegroups.com
Am 04.01.2013 23:57, schrieb Joshua Granick:
> NME 3.5.3 was re-released with minor changes to preserve compatibility
> with the most recent Haxe SVN.
>
>
after updating I get:
C:\Motion-Twin\Haxe\lib\nme/3,5,3/browser/Lib.hx:1138: characters 14-33
: Unknown identifier : js

after commenting out the
if haxe_211 inside of the window getter/setter compilation went fine -
however one question google did not answer:

how to setup the nme project template to build only html5 ?

currently it runs like:
haxelib run nme build C:\devel\haxe\HTML5\application.nmml flash -debug
-Dfdb

I could not figure out where the flash part is set and can be changed to
javascript

Jan_Flanders

unread,
Jan 5, 2013, 10:33:20 PM1/5/13
to haxe...@googlegroups.com


On Friday, January 4, 2013 4:27:16 PM UTC+1, Axel Huizinga wrote:
Regarding the hxswfml tool I found that it doesn't work perfectly in all cases (Museo 400 Font):

see http://paradiseprojects.de/devel/js/cufon_nme.html

the first line was created with cufon's converter the second was a test with hxswfml and a nme sample project.
 
This should be fixed now in latest hxswfml (svn version).

Best,

Jan
Reply all
Reply to author
Forward
0 new messages