Objects API

FLX language provides an API for defining objects that have properties and methods. A defined object can have any number of instances, but inheritance is not supported. An object is defined with an object model that may contain following member definitions:

  • Immutable (val) properties
  • Mutable (var) properties
  • Methods

Each defined object (e.g. Robot) has a single constructor (e.g. Robot.new) for creating instances of the object. Below is an example of an object model, object instantiation and usage of the created instance.

  1. An object model with object name Robot.
  2. Constructor of Robot object which creates a new instance of Robot.
  3. The property setter for property x of Robot.
  4. The property setter for property y of Robot.
  5. The property setter for property direction of Robot.
  6. Creating an instance of Robot using the defined spawnRobot function.
  7. Function is can be used to check if an instance is of the specified object type.

The following screenshot contains an example of an object definition with object properties and methods:

  1. Object model Robot opened.
  2. Mutable (var) property definitions.
  3. An object method onHit.
  4. Another object method of Robot. called onDestroyed.