Integration Guide

Table Of Contents
Digital Goods Integration Guide - EC Edition January 2012 51
B
Methods For Integrating Digital
Goods Into Flash
You can integrate digital goods into a Flash file.
“Integrating Digital Goods With Flash - Third-Party Merchant” on page 51
“Integrating Digital Goods With Flash” on page 51
Integrating Digital Goods With Flash
The following is an example of how a first-party merchant can integrate digital goods with
Flash.
To integrate digital goods with Flash:
1. Include the digital goods JavaScript library in the HTML page game.html, which also
includes the Flash movie game.swf.
2. Include the following ActionScript in the Flash movie game.swf to initialize the digital
goods object:
dg_button.addEventListener(
MouseEvent.MOUSE_UP,
function(evt:MouseEvent):void {
var payment_URL:String = "<Merchant URL to initiate API call>";
// use ExternalInterface to call the JavaScript method dg.startFlow
var result:uint =
ExternalInterface.call("dg.startFlow",payment_URL);
}
);
function paymentComplete(responseText):void {
// use responseText to do any customizations
}
// register the callback method so it can be called via JavaScript
ExternalInterface.addCallback("paymentCompleteExt", paymentComplete);
Integrating Digital Goods With Flash - Third-Party Merchant
The following is an example of how a third-party merchant can integrate digital goods with
Flash.
In the following example, use ActionScript 3.0’s LocalConnection in the Flash movie,
game.swf, to respond to the payment.