This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
A Framework for Recording and Playing Back Componentized Applications
effectively trap any change to the Input Text field, regardless of who generated the
We want to do this only if the component is being recorded, so it makes sense to
define the onSync( ) handler in the setRecorder( ) method definition. Add this code to
the PTextField.asc file:
PTextField.prototype.setRecorder = function (p_recorder) {
this.m_recorder = p_recorder;
this.m_recorder.addEventListener("onRecordingEvent", this);
// Use the SO on the server side for recording only.
this.m_so = SharedObject.get(this.m_id + "_text", false);
this.m_so.owner = this;
this.m_so.onSync = function (p_list) {
if (this.owner.m_isRecording)
"textChanged", [this.getProperty("text")]);
First, the code adds the PTextField component as a listener to the global R&P Man-
ager (which will trigger the onRecordingEvent( ) method whenever a master stream
starts or stops being recorded).
Then the code gets a reference to the shared object and defines an onSync( ) for it.
The onSync( ) handler checks whether the component is being recorded and, if so,
asks the global R&P Manager to record a textChanged event containing the text for
The next thing to do is define an onRecordingEvent( ) method, which will be trig-
gered by the R&P Manager. Add this code to PTextField.asc as well:
PTextField.prototype.onRecordingEvent = function (p_eventObj) {
this.m_isRecording = (p_eventObj.value == "start");
if (this.m_isRecording)
this.m_so.onSync( ); // Generate an onSync event.
This function sets the m_isRecording flag depending on the event being triggered
value can be “start” or “stop”).
Also note how we generate an artificial onSync event whenever a recording is started,
to record the initial state of the Input Text field.
That’s all that’s needed to make PTextField recordable. Now let’s look at how to
make it replayable.
Making PTextField Replayable
All the code necessary to make PTextField replayable is added to the client-side file.

Get Programming Flash Communication Server now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.