FMXISEventRecorder

Availability

Flash Player 6 r65.

Description

The event recorder provides a basic mechanism to record and playback a series of events issued to FMXIS components, or any component that defines an execEvent method. This functionality might be useful in that a subject-matter expert could record a sequence of actions on a device, store that sequence, and then playback that sequence as part of a help function in the training (or even a wizard type of functionality).

Important: This recorder does not take a snapshot of the system state before recording, it merely records any sequence of events it receives once the user has started recording. For playback, it does not set the system in the original state as when the recording took place--the developer must do this in whatever way is appropriate for the simulator.

FMXISEventRecorder component panel.

You use the record event features, do the following:

  1. Drag and drop the component on the Stage of a simulator from which you want to record events.
  2. Name the instance of the recorder.
  3. In a keyframe action, add the recorder as a listener to all components you want to monitor. For example, if the recorder's name was recorder, and a FMXISPotentiometer's instance name was pot, you would say pot.addListener(recorder); , or pot.addEventListener("onValChg", recorder); .
    Note: the recorder does not have to be on the same movieclip timeline as the components. If the recorder is on a different (higher) timeline, change the Movie clip instance property of the recorder to the movie clip in which the components reside.
  4. When you are ready to record a sequence, press the green record button () and begin interacting with the components.
  5. If you want to pause the recording, press the pause () button. If you want to restart the recording, press the rewind () button. If you want to stop the recording for good, press the stop () button beneath the Recording label.
  6. You can use the playback controls (play and stop ) to see if it captured the events you needed. Re-record as necessary.
  7. Retrieve the sequence of events by pressing the button marked "Output" and copying the text that appears in the box on the right. Tip: If you receive the text "[no recorded events]", it means you did not set up the recorder to listen to the events correctly. Check your code that sets up the listener to the recorder.

Once you have the sequence of events, you can store them in a function or method, and then play them back whenever you want. To play back a sequence of events, you need to have the FMXISEventRecorder component on the Stage. The simulator can be in a different position during playback from where it was during recording. The event recorder uses the relative position of the simulator (given in the movie clip instance property of the event recorder) as an offset for the cursor, rather than assuming the same positioning from recording to playback.

You most likely will need to clean up the events with respect to timing and sometimes mouse position. You can also filter the events in case it has recorded events you don't want to playback. Let's look at an example sequence produced by the recorder:

ra.recObjs.push(new mx.fmxis.recordedEvent(22, 156, 234, ra.targClip.b1, "onSet")); 

The key elements are the arguments to the recordedEvent constructor. The first parameter is the number of milliseconds since the last event occurred. The second and third parameters are the x and y coordinates of the mouse when the event occurred. The fourth parameter is the component that generated the event, and the fifth parameter is any value associated with that component.

To playback the events, do the following:

  1. Drag and drop the component on the Stage of a simulator into which you want to play events. Make sure the recorder component is at the highest layer, above the components which you will be recording. If you place it differently from where you had it when recording, adjust the code in the event sequence appropriately.
  2. Name the instance of the event recorder the same name as you made it for the recording.
  3. Adjust the movie clip instance property of the recorder to indicate the movie clip level (timeline) of the simulator.
  4. In the property panel of the event recorder, make sure that the display panel property is set to false.
  5. Put the code for the sequence of events wherever you want to trigger it.
  6. (optional) Have fun!

By default, the playback mechanism starts the cursor at the actual user mouse position. If you want to start the cursor somewhere else, set the value for X and Y coordinates in the recorder property panel. If you want to set the cursor back to start at the mouse position, enter "mouse", or simply something non-numeric.

Replacing the Cursor

We have made it possible to replace the default cursor with whatever graphic you want. Simply create a new movie clip with the functions outlined below, and assign it a linkage ID. In the event recorder panel, type the linkage ID in the cursor linkage ID property value.

A custom cursor must define the movie clip with the graphic such that the upper left corner is the hotspot. You also must define two functions within the movie clip:

  1. showCursor(f) : Takes a Boolean value (f) and makes the cursor visible (f == true) or invisible (f == false).
  2. activateCursor(f): Takes a Boolean value (f) indicating whether or not to activate a cursor animation, if any.

Methods of the Event Recorder

Here are the public events for the event recorder:

Playback:

Record:

Properties of the Event Recorder

Here are the public properties for the event recorder. The properties must be set at initialization time, and therefore are only respected when set through the property inspector.