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
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.
- An object model with object name Robot.
- Constructor of Robot object which creates a new instance of Robot.
- The property setter for property x of Robot.
- The property setter for property y of Robot.
- The property setter for property direction of Robot.
- Creating an instance of Robot using the defined spawnRobot function.
- 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:
- Object model Robot opened.
- Mutable (var) property definitions.
- An object method onHit.
- Another object method of Robot. called onDestroyed.