| Important: From a system demand point-of-view, it is better, if possible, to use environment variables rather than participant variables. The reason is that when you define a participant variable, every participant has a unique one, and if you have 20 participants, that's 20 different values. When you define an environment variable, it is not duplicated for each participant. System performance, based on the Flash Communications Server, may be affected as you get more than 50-100 variables. |
CommandSim allows you to define scenario variables to hold data that your visuals may use to provide the right cues. For example, you may want the first-in engine to come to a closed door, but once they go through the door, you want others to see it as open.
Environment variables are elements you create that hold a value. The node visuals you create (using Flash) can read and set those elements, and thereby adjust their visual and any computation based on the value. In the door example (above), therefore, you could have an environment variable that stored the door position and then the node visual would refer to the variable's value to draw the correct look.
Participant variables are elements used to hold values specific to each participant. For example, each participant might have a variable to hold the amount of air left in his or her SCBA tank. Each participant's variable can be modified independently of other values.
Environment and participant variables are on the advanced side of CommandSim since they require programming in the Flash files. However, with a basic introduction, they are not tricky at all to set up and use.
The first step is to create an environment or participant variable. You do this in the "Scenario States & Variables" tab of the scenario design tool:

To add an environment variable, you click the Add button beneath the Environment Variables list. Similarly, you can create a participant variable. A dialog box opens to ask you for three pieces of information:
- Name: The name of the environment variable. This name is shown to instructors when they choose to view or alter the variable's value. It may contain spaces.
- ID: This is the identifier of the variable. It is used by the system to identify the variable. It must not contain spaces or special characters. When you refer to the variable in your Flash programs, you use the ID, not the name. The identifier must be unique from other environment variables.
- Value: This is the default value for the variable.
When an instructor starts a session, CommandSim creates the set of environment variables and assigns them their default value. Instructors can override the default values through the instructor panel. Participant variables are created when each participant joins the exercise.
The Flash Side of Variables
To make your node visuals react to variable changes, you define the following functions:
- eVarValChg: Define this function to receive notification when an environment variable changes. On such changes, CommandSim will call this function passing two values, the identifier of the environment variable (NOT the name), and the current value. Therefore, you will typically write this function as:
function eVarValChg (id, val) {
switch (id) {
case "windDir":
// do something based on new wind direction
...
}
}
- pVarValChg: Define this function to receive notification when the instructor has changed a participant variable for the current participant. On such changes, CommandSim will call this function passing two values, the identifier of the participant variable (NOT the name), and the current value. Therefore, you will typically write this function as:
function pVarValChg (id, val) {
switch (id) {
case "tAir":
// do something based on new tank air
...
}
}
Your node visual can also change values as well as react to them changing. You use the following routines to read and change variables in your node visual movie:
Important: These functions are not global; you must prefix a call to them by the correct number of _parent prefixes necessary to get to the level at which they are defined in the participant container movie. If you are programming on your main timeline in your visual, the correct prefix is _parent._parent. Add more _parent prefixes as necessary if you are in sub-timelines in your visual movie.
For node visuals that are sensitive to variable values, you should retrieve the values when your visual first loads and set the conditions appropriately. Here is an example of startup code (placed in first keyframe of node visual movie):
function eVarValChg(id, val) {
switch (id) {
case "windDir":
// make visual change for wind direction
break;
}
}
function pVarValChg(id, val) {
switch (id) {
case "myTankAir":
// make visual change for my air tank
break;
}
}
setUpWind(_parent._parent.getEnvironVar("windDir"));
setAirLevel(_parent._parent.getParticipantVar("myTankAir"));
Environment variables are elements you create that hold a value. The node visuals you create (using Flash) can read and set those elements, and thereby adjust their visual and any computation based on the value. In the door example (above), therefore, you could have an environment variable that stored the door position and then the node visual would refer to the variable's value to draw the correct look.
Participant variables are elements used to hold values specific to each participant. For example, each participant might have a variable to hold the amount of air left in his or her SCBA tank. Each participant's variable can be modified independently of other values.