Game Development Reference
In-Depth Information
Defining a class
The contents of the HelloWorld.as file should be as follows:
package {
import flash.display.Sprite;
public class HelloWorld extends Sprite
{
public function HelloWorld()
{
}
}
}
Flash Builder always creates a main class with the same name as the project name,
in this case, HelloWorld. The main class is what gets loaded first when the program
starts the execution.
Let us go ahead and add a statement that will output the string "Hello World" like
the following:
public function HelloWorld()
{
trace("Hello World");
}
Notice that we are using a global function called trace offered by the Flash library,
which takes in a string as a parameter and prints to the console view of the Flash
Builder. Note that in order to view the output, we should run our program in
debug mode.
 
Search WWH ::




Custom Search