Creating an Ad Display SWF requires advanced development skills. This feature is intended for use by ad network and ad serving partners with complex ad delivery requirements. If you are a Brightcove customer and think your project or product calls for use of the Brightcove Ad Display SWF, please first contact your Account Manager to see if one of Brightcove's ad partners would work better for you.
This document describes how to create an Ad Display SWF. By default, a Brightcove player expects ads to be returned in XML format. Using an Ad SWF enables the use of Flash SWF-based ad components or modules. This opens up many possibilities for how an ad can look and behave.
If you want to deliver/render a unique Ad Format in your Brightcove player, that is not one of Brightcove's standard Ad Formats, you can develop your own Ad Display SWF. The Ad Display SWF is an advanced tool which is often used for development by advertising partners.
Just like other ad formats, the Ad Display SWF has an XML specification, which looks like this:
<adSwf version="1" trackStartURLs="http://trackingurl"> <adSwfURL>http://path-to-ad-swf.swf</adSwfURL> <optionalArg>arg value 1</optionalArg> <anotherArg>arg value 2</anotherArg> </adSwf>
When the player receives an ad in this format, it retrieves and executes the SWF at the specified URL. The SWF can then make an additional call or calls for the ad content itself as well as handle all the rendering and user events. An Ad Display SWF can be linear or non-linear, acting like a video ad or an overlay ad. Special APIs are provided to have linear ads act similar to Brightcove's built-in video format.
To help you learn how to write Ad Display SWFs, you can download a zip file, AdSwfDevKit.zip, that includes the following resources:
ExampleAdSwf.as and Example.swfExampleTranslator.as and ExampleTranslator.swfbc_ads.swcTo learn about creating and using Ad Display SWFs, set up the example and see how it works. The main steps in setting up the example are:
We provide an Ad Translator in the AdSwfDevKit.zip example zip so that you can easily try out the example ad SWF. You do not have to use the example Ad Translator. Instead of using the Ad Translator, you could just traffick the example Ad Display SWF as you would any other ad on your ad server. The Ad Translator, however, allows you to see the Ad Display SWF in the example without trafficking it on your ad server.
To set up the Ad Translator, you can either compile ExampleTranslator.as or just use the already-compiled ExampleTranslator.swf. To start with ExampleAdSwf.as:
bc_ads.swc and ExampleTranslator.as from AdSwfDevKit.zip. Create a project in your development environment with ExampleTranslator.as as the main class.bc_ads.swc as an external library. Make sure that you add it as an external library, rather than putting it in the library path. Otherwise, your SWF will be slightly larger than it needs to me. If you are using Adobe Flex Builder, you can add it as an external library in the "Additional Compiler Options" by adding -external-library-path=../bc_ads.swc . If you are using Adobe Flash, you can simply drop bc_ads.swc into the same directory as your application .fla before you compile.ExampleTranslator.as and put the resulting SWF on a web server where your players can access it. We'll use this SWF later.To use the already-compiled ExampleTranslator.swf:
ExampleTranslator.swf from AdSwfDevKit.zip.The next step is to compile and host the example Ad Display SWF. You can either compile ExampleAdSwf.as or just use the already-compiled Example.swf. To start with ExampleAdSwf.as:
bc_ads.swc and ExampleAdSwf.as from AdSwfDevKit.zip. Copy these files to a different folder than the one used for the Ad Translator project.ExampleAdSwf.as as the main class.bc_ads.swc as an external library. Make sure that you add it as an external library, rather than putting it in the library path. Follow the same steps that were done for the ad translator above.ExampleAdSwf.as and put the resulting SWF on a web server where your players can access it.To use the already-compiled Example.swf:
Example.swf from AdSwfDevKit.zip.Now that we have compiled and hosted the Ad Translator SWF and Ad Display SWF, we can use these two elements together to traffick an Ad Display SWF:
adSwf=http://host/adSwf.swf, changing the URL to the real location of your Ad Display SWF.Now that you've seen how the Ad Display SWF works in the example, you should be able to see how to create your own Ad Display SWF. You can use the example, ExampleAdSwf.as, as a starting point. Your Ad Display SWF should follow the same basic structure. Review the comments in ExampleAdSwf.as to help you understand what is going on. As in ExampleAdSwf.as:
com.brightcove.fl.advertising.adswf.AdSwf.Security.allowDomain("admin.brightcove.com") so that crossdomain.xml doesn't need to be set up for the SWF to communicate with the Brightcove player SWFsdisplayAd() function. This is the function which displays the ad. It will often load another SWF that is the actual ad. The function can change the state of the player or initialize the ad with AdSwfContext. The player APIs can be accessed through AdSwfContext, which allows the Ad Display SWF to get information about different BEML components, change the ad display state through functions like showSponsorMessage(), get the size and location of the video player, and a lot more.adComplete() to return control to the player. Make sure to remove any event listeners that have been set up.