Skip to main content

Packages and Modules

Flex uses packages and modules to create namespaces. Modules contain your Flex code, and packages contain your modules. To start writing Flex code, you'll first need to create a package.

Creating a Package

To create a package:

  1. Click the blue New Package button
  2. Enter a Package Name and select a Team

Package names may contain letters a-z,A-Z, numbers 0-9, and two colons :: as a delimiter. They must begin with a letter. You can choose the team that the package belongs to. This allows other team members to access your package.

Forking a Package

Existing packages can be forked. This allows you to customize them.

To fork a package:

  1. Hover over a package in the left side file viewer and click the ellipsis β‹― icon
  2. Click Fork Package
  3. Enter a Package Name and select a Team

Alternatively, you can click the Fork Package button while viewing the Package Manager.

note

Only published packages can be forked.

Creating a Module

To create a module:

  1. Hover over your package in the left side file viewer and click the ellipsis β‹― icon
  2. Click New File, or New Folder if you wish to group files
  3. Enter a File Name (this will be the name of your module)

Modules are Flex files. Module/file names may contain letters a-z,A-Z, numbers 0-9, and underscores _. They must begin with a letter or an underscore.

After creating a module, you will be taken into the Flex Editor where you can write Flex code.

Module Structure

Module contents are comprised of three parts:

  1. Module Name
  2. Import Statements
  3. Flex Code

Module Name

After creating a new file, you'll see the module name declared automatically at the top:

flex
module packageName.moduleName

Import Statements

Other modules can be imported which allows you to access and extend their objects and methods. Import statements are entered below the module name.

To import a module with an alias:

flex
import packageName.moduleName as aliasName

To import specific objects from a module:

flex
import packageName.moduleName (objectName, functionName, ...)

Flex Code

Flex code is added below the module name and import statements.

flex
module MyPackage.Routing
import OpenUxAS::LMCP::v3.afrl.impact as lmcp_impact
import OpenUxAS::LMCP::v3.afrl.cmasi (AirVehicleState, Location3D)
struct Route {
Start: Location3D;
Stop: Location3D;
State: AirVehicleState;
}

To learn more about writing Flex code see Flex Syntax Overview.

Publishing a Package

To publish a package:

  1. Hover over your package in the left side file viewer and click the ellipsis β‹― icon
  2. Click Publish Package

Alternatively, you can click the Publish Package button while viewing the Package Manager.

Publishing your package allows you to use your messages and transforms in Tangram ProTM component software interfaces. To try it out, check out our tutorial Author a Message Set with Flex.

Note, each time a package is published a new read-only version is created, and appended with an incrementing version number. For example, if the package name is MyPackage, then the first published version will be named MyPackage::v1, and the second MyPackage::v2.