-
Notifications
You must be signed in to change notification settings - Fork 32
Tutorial ~ Writing Jangaroo Code
Jangaroo source files look like ActionScript 3 and thus share the extension
.as
. In the following we are going to create the most simple "Hello World"
example in _PROJECT_HOME_/src/main/joo/HelloWorld.as
.
This is the Jangaroo source code of HelloWorld
:
package {
/**
* The most simple Jangaroo class on earth.
*/
public class HelloWorld {
/**
* Let the browser display a welcome message.
*/
public static function main():void {
window.document.body.innerHTML = "<strong>Hello World from Jangaroo!</strong>";
}
}
}
Note that each Jangaroo class must be contained in a package, here the top-level
package is used. The package name defines the location of the file below
the source directory. In this case, the file must be located directly in
_PROJECT_HOME_/src/main/joo/HelloWorld.as
.
As you can see, the example class defines one static method, main. Like in Java, this method is called when starting the application.
This method simply assigns a markup string to the document body, so the greeting message is displayed in the browser.
To learn all about the language features of Jangaroo you should check out the language reference.
Eventually, we want to use this code in our web application and run it in the browser. This is where the Jangaroo Maven build process enters the picture.
Overview | Applications | Tutorial | Project | Documentation | Download | Blog | FAQ | Imprint