Prev | Current Page 314 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


> haxe -js main.js -main Main.hx
In the main function, a Panel instance is created and used just as if it were defined in the haXe project.
Then a reference to the two buttons is created and used to add the behaviors to their onclick events.
The object document represents the entire page content and has a method getElementsById(name)
that looks for a single element in the page with the attribute id equal to name . Because this function
always returns an object of type js.Dom , it is necessary to cast it to the proper typedef Button . Note
that the majority of the structures in the js package is mapped as a typedef and not as a class .
The sample page is very simple. It defines a style for the box, two buttons, the box to use with the Panel
class and finally the inclusion of the external library and the haXe application. It is important to note that
the JavaScript code will act on the structure of the HTML and to be sure that the DOM (Document Object
Model) is ready to be modified, the .js files are included as the last elements.


Pages:
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326