Developer Resources

Application

Overview

The application class represents a script application and is primarily reponsible for starting and stopping the script event loop. In event-oriented programming, the event loop drives the user interface aspects of the program, and coordinates the connection between the program code and the user's actions. Using the Application object allows the usage of Forms and interactive script programs.

Methods

Application.exit
Exits the event loop and stops the script from running.
Application.run
Starts the event loop for a form.

Example

// create an instance of our derived MyForm class
// and show it
var f = new MyForm;
f.show();

// start the event loop.  At this point in the script, execution
// is turned over to the event loop, which the Application class manages.
// Execution will proceed from here only after Application.exit is called.
Application.run();

alert("This message appears after the event loop has exited.");



// our Form-derived class
class MyForm extends Form
{
    function MyForm()
    {
        super("Hello World", 100, 100, 200, 100);
        this.add(new Label("Click on the form to stop the application.",
                           5,5,100,100));
        this.mouseLeftUp.connect(exitFunction);
    }
}

function exitFunction()
{
    // calling Application.exit() will terminate the event loop.  Execution
    // will continue in the same scope in which Application.run() was called
    Application.exit();
}

Application.exit

static function Application.exit()

Description

Exists the event loop and stops the script from running.

Application.run

static function Application.run()

Description

Starts the event loop for a form. When using forms in a script, this function must be called before the form can register events.