Using Flash with ExternalInterface

ExternalInterface allows data to be passed in and out of the Flash object (a getURL is a static one-way command). Because of the added flexibility, this method allows Webtrends new interactions to happen as they are developed. Further, this method allows Webtrends to continue to collect hits in Internet Explorer for lengthy parameter lists.

ExternalInterface is recommended because the getURL function was removed from the ActionScript language in version 3.

ExternalInterface is also especially useful for large implementations, where rewriting the dcsMultiTrack call for each button on the website is time-consuming. In this case it makes sense to use a more modular approach. The advantage to this method is that the parameter names only need to be defined once. After definition, the values for those parameters change only when the actual click occurs. This is effective for large implementations that have many parameters that are passed on each click.

In ExternalInterface, the dcsMultiTrack syntax is placed in its own function within Flash. When each button calls the function, it also passes in parameters. For example, you could implement the following function on the "actions" layer of a Flash movie:

function trackEvent(value1,value2){
if (ExternalInterface.available) {
try {"dcsMultiTrack","DCS.dcsuri",
value1,"WT.ti", value2);
} catch (error:Error) {
// error handling here
} catch (error:SecurityError) {
// error handling here

While this syntax is very similar to the standard getURL syntax, it has not been executed yet. An action needs to call the function. Associate the following code with every Flash button tracked:

on(release){ trackEvent('value1','value2'); }

In this case, your ActionScript syntax may look similar to the following example:

As in the getURL examples, this code can be embedded either in the first frame of a movie, or in an event handler.

Note: This usage of the ExternalInterface object assumes that the HTML page (with the Webtrends JavaScript code) is the container for your Flash application. Implementations that do not use HTML as the container for Flash applications are more complex and may require the engagement of a Webtrends Professional Services engineer to assist you with your implementation.