The http://ActionScript.org Staff are Jesse Stratford and Evgueni Strok. The original founders of this site in 2000, Strok and Jesse live thousands of miles from each other and have never met in person...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.
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:
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
| Nothing |
To write messages from a Flash movie application to the Active Log we can use the following Flash-JavaScript methods of communication:
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);
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.
Here are the steps you should follow to implement this demo example:
This is the completed ActionScript:
import flash.external.ExternalInterface; // Register events cmdLog.addEventListener(MouseEvent.CLICK, cmdLog_onClick); cmdXml.addEventListener(MouseEvent.CLICK, cmdXml_onClick); // Writes a message to the Active Log function cmdLog_onClick(event:MouseEvent):void { ExternalInterface.call("ActiveLog.Trace", txtMessage.text, txtTitle.text); } // Generates XML and populate txtMessage textarea function cmdXml_onClick(event:MouseEvent):void { var xmlDoc:XMLDocument = createSampleXml(); txtMessage.text = xmlDoc.toString(); } // Creates sample XML // @return sample XMLDocument function createSampleXml():XMLDocument { var xmlDoc:XMLDocument = new XMLDocument(); var xmlNode:XMLNode = xmlDoc.createElement("ADDRESS"); xmlNode.appendChild(createXMLNode("BUILDINGORHOUSENUMBER","525",xmlDoc)); xmlNode.appendChild(createXMLNode("STREET","Chaplin Crescent, SW",xmlDoc)); xmlNode.appendChild(createXMLNode("CITY","Toronto",xmlDoc)); xmlNode.appendChild(createXMLNode("PROVINCE","ON",xmlDoc)); xmlNode.appendChild(createXMLNode("POSTALCODE","M5N2N2",xmlDoc)); xmlNode.appendChild(createXMLNode("COUNTRY","Canada",xmlDoc)); xmlDoc.appendChild(xmlNode); return(xmlDoc); } // Creates XMLNode with text // @param name XMLNode name // @param text XMLNode text // @param xmlDoc XMLDocument to create XMLNode // @return XMLNode function createXMLNode(name:String,text:String,xmlDoc:XMLDocument):XMLNode { var xmlNode:XMLNode = xmlDoc.createElement(name); var xmlTextNode:XMLNode = xmlDoc.createTextNode(text); xmlNode.appendChild(xmlTextNode); return(xmlNode); }This is the completed JavaScript placed in the HTML head:
function jsoActiveLog(bActiveLogMode) { // Constructor // @param bActiveLogMode - Boolean value( true or false ) whether to turn Active Log on. function jsoActiveLog(bActiveLogMode) { this.ActiveLogMode = bActiveLogMode; this.ActiveLog = null; try { this.ActiveLog = new ActiveXObject("VAALOG.ActiveLog"); } catch (e){ this.ActiveLogMode = false; } } // Logs message to Active Log. // @param message - Text message to be logged. // @param title - Message title that is displayed in the message list pane. jsoActiveLog.prototype.Trace = function Trace(message, title) { if(this.ActiveLogMode) this.ActiveLog.LogData(message, title); } return new jsoActiveLog(bActiveLogMode); } var ActiveLog = new jsoActiveLog(true);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.