Prev | Current Page 67 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


Like in the previous examples, you can compile the hello world example for JavaScript by making a
simple alteration to the original .hxml file. Open the file now and replace its content with the following
code:
-js helloworld.js
-main HelloWorld
As before, all you have to do is to change the first switch to a ??“ js switch and then change the file
extension of the output file to .js .
Compiling should now produce a file called helloworld.js as expected. However, you will not be able
to run this file, yet. First, you need to create an HTML file that will call your JavaScript code.
Unlike Flash, JavaScript is heavily associated with HTML. The JavaScript DOM (Document Object
Model) provides a hierarchy that maps to the structure of an HTML document and exposes hooks to
each of the HTML elements. As a result of this, it is necessary for an HTML page to call its associated
JavaScript document rather than allowing JavaScript code to run on its own.
22
Part I: The Core Language
Create a new document called helloworld.


Pages:
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79