Summary
This is a step-by-step article that will guide you through the entire process of
using VATech System's Active Log to log messages from Flash movie during runtime.
Introduction
Active Log is a Windows ActiveX application that can be easily plugged to web clients
in Internet Explorer browser to log, view and analyze text messages. It can be used
as diagnostic trace and log to provide you with information that shows internal
processing of operations in your Flash application.
Active Log is extremely useful for logging and analyzing the interaction history
between client and server for the following web applications:
- Multiplayer applications such as chatting system and games
- Flash message boards and forums
- Flash RSS viewers
How to use the Active Log
Active Log is a Windows ActiveX application. It can be launched in Internet Explorer
browser through JavaScript by calling the ActiveXObject
object constructor:
var ActiveLog =
new ActiveXObject("VAALOG.ActiveLog");
Use the LogData method to write a message to Active Log:
ActiveLog.LogData(message,title);
Parameters
|
message
|
Text message to be logged.
|
|
title
|
Message title that is displayed in the message list pane.
|
Returns
To write messages from a Flash movie application to the Active Log we can use the
following Flash-JavaScript methods of communication:
-
getURL() for earlier versions of Flash Player 8.
-
fscommand() action.
-
ExternalInterface class introduced in Flash Player 8 that enables ActionScript to
call any JavaScript function on the HTML page directly with passing any number of arguments
of any data type and receiving a return value from the call.
In this example, we will use ExternalInterface class to invoke Active Log's
LogData
method from Flash movie. The ActionScript code below demonstrates
this approach.
ExternalInterface.call("ActiveLog.LogData",
message,title);
Live Active Log Example
This live demo demonstrates how Active Log can be used to log messages from Flash
movie during runtime.
Note This demo works in IE browser only.
Click Proceed To Demo to launch the demo.
Walkthrough: plugging Active Log to Flash movie
Here are the steps you should follow to implement this demo example:
-
Install Active Log
.
-
Create a new ActionScript 3.0 Flash Document in Adobe Flash. Save the file with
the file name: ActiveLogEx.fla.
-
Place a TextInput component on the stage and give instance name of: txtTitle.
-
Place a TextArea component on the stage below the txtTitle
and give instance name of: txtMessage.
-
Place 2 Label components on the stage before text components and set Text
properties to Message Title and
Message
Body
.
-
Place 2 Button components on the stage below the txtMessage
and give in instance names of: cmdXml and
cmdLog
.
-
All of the code for the movie will be in Frame 1. Select the frame one of Layer
1 (or make a new layer for your ActionScript) and open the Actions Panel.
-
Use ActionScript External API ExternalInterface.call method
which, in this example, will invoke a JavaScript ActiveLog.Trace
function that will call LogData method in Active Log.
The parameters passed into that function in JavaScript will be set to
txtMessage.Text
and txtTitle.Text in
cmdLog_onClick
event handler.
This is the completed ActionScript:
-
Open the HTML created when having published the SWF for ActiveLogEx.fla.
-
Within the head tag of the HTML, insert the JavaScript
jsoActiveLog function used to interact with the Flash
movie and pass messages to the Active Log.
This is the completed JavaScript placed in the HTML head:
Conclusion
The ActionScript trace statement already provide mechanism
to display messages in the Output panel while testing a SWF file. However, several
factors make Active Log a suitable technology for logging messages in real-time.
In this article, we've covered the basics of using Active Log, and we've seen the
example of a plugging Active Log to Flash movie step by step. Many developers and
system administrators can benefit from its use.