Note: This article describes legacy techniques in Flash video. To learn about the latest best practices for working with video in newer versions in Flash, please read the Flash Video Learning Guide and the most recent articles posted in the Flash Video Developer Center.
Video in interactive advertising provides a powerful opportunity for advertisers to communicate directly with their customers. Web audiences respond much more significantly to video when it is used properly in interactive advertising. Whether using video to create a brand impression or deepen awareness of product features, marketers now have the best of both worlds: the communication benefits of video and the interactive capabilities of the Internet.
The Macromedia Flash Ad Kit lets advertisers combine immersive video with rich interactivity in a seamless, efficient manner. The Flash Ad Kit allows an unprecedented analysis of ad effectiveness through the automated tracking of clickthroughs and unique events.
To view this content, you need the latest version of the Macromedia Flash Player.
Download the free Macromedia Flash Player now.
Example of video within an ad (click the Watch tab)
This article shows you how to use the Flash Ad Kit, integrate the media components included with Flash MX Professional 2004, link to streaming video on the Flash Video Streaming Service, and deploy an ad through the DoubleClick DART Motif ad server. In order to follow along, download and save the sample files into a folder on your hard drive.
The Macromedia Flash Ad Kit automates clickthroughs, the loading of external movies, event tracking, and timer tracking in Flash-based rich media ads. The Flash Ad Kit currently integrates with the DoubleClick DART Motif ad server to provide unparalleled information on ad effectiveness.
Flash Ad Kit templates provide a standard timeline, code to communicate with DART Motif, and code to automate the creation and tracking of rich media ads. A general Flash Ad Kit template consists of four layers: Instructions, Links and Descriptions, Script, and Content (see Figure 1):
Figure 1. The standard Flash Ad Kit general template layers
External movies such as Flash streaming video (FLV) files are easy to load into Flash Ad Kit movies. This allows you to host a rich media ad on the DART Motif ad server and gain all of the Flash Ad Kit's tracking capabilities, while still accessing a video stream from an external server dedicated solely to video hosting. You get the best of all worlds by creating interactive ads with video in this manner.
In order to create a video ad for an advertising client, it's crucial to ensure that you have a robust Flash Communication Server MX hosting solution for your Flash streaming video. This streaming server technology is an ideal platform for hosting and deploying video using the Flash Ad Kit because video starts playing immediately for your audience and the quality of the video is much higher than trying to embed video directly into Flash movies.
You can purchase Flash Communication Server MX and set up your own video server. If you decide to host your own content, then some critical issues you must consider include server uptime, server maintenance, bandwidth availability, and load balancing. Because ads are often displayed in large quantities at the same time, server loads can spike dramatically. In general, you will get better results by using an outside video hosting company rather than hosting the streaming video yourself.
The Flash Video Streaming Service (FVSS) gives you access to Flash Communication Server for your ads. This useful service allows you to begin broadcasting video through your rich media ads by signing up for an account and uploading Flash Video files. The FVSS provides clients with full audio and video streaming capabilities with minimal hassle and cost. Macromedia-approved service providers offer built-in load balancing to handle large spikes in traffic. The FVSS makes creating and deploying rich media ads with video a simple and straightforward process.
In some cases, Flash Player 7 will not load movies or data from external domains. Although it is easy to add cross-domain functionality, it requires adding a small cross-domain policy file to the hosting provider's web servers or adding code to your Flash movies. Useful information about the Flash Player security features can be found in Deneb Meketa's article, Security Changes in Macromedia Flash Player 7.
In this article you will create a tabbed ad that contains an introductory graphic, a viewer-selected video in an external movie, and a fill-in form. You can review the finished ad in the goAwayAd.fla movie. The first step in creating a rich media ad using the Flash Ad Kit is to select a Flash Ad Kit template and design your ad.
Deciding on a template is relatively straightforward:
The Flash Ad Kit provides several different types of ad templates for expandable ads and a general template for all other kinds of Flash ads (see Figure 2). Select the general template and click OK.
Figure 2. Selecting from the ready-to-use Flash Ad Kit templates
Publisher site requirements generally do not allow a Medium Rectangle to be more than 30K; on some sites the maximum is 20K. Usually time constraints force you to create ads for the lowest common denominator publisher, so make goAwayAd.swf a 20K ad.
In order to minimize the file size of the base Flash ad to meet the publisher's site requirements, an external SWF file containing the video elements is loaded when the viewer clicks a button to view the video. If the video were contained in the main ad, there would be no way to fit it into the 20–30K maximum size that most publishers require for Medium Rectangle rich media ads.
Before continuing with the rest of the tutorial, load goAwayAd.fla and open the Library panel. Now you can use the assets in its library to recreate this ad. Be sure to click on the goAwayAdLearn.fla tab before continuing.
Select the Content layer and insert 10 new layers. From top to bottom, name the layers beneath the Script layer as follows:
A useful beginning of the design phase is to think about the kinds of interactions you want to track within the ad. In this ad, useful events to track could be the selection of each tab, the time spent in each tab, user selection of the video, length of time the user watches the video, and user drop-off from the fill-in form.
Each ad made with the Flash Ad Kit requires a clickthrough URL. In this ad, it goes to the home page of the Flash Ad Kit:
On Frame 10 of the Script layer. add the following code to automate and track the clickthroughs:
clickThrough.onPress = function(){
_root.conduit.exit(1);
}
You can either enter the above exit code by hand or enter it automatically from the Flash Ad Kit functions folder on the left side of the Actions panel. In the set of Event Functions under the Flash Ad Kit folder, double-click the "exit" function to add it to your code (see Figure 3). Add 1 between the parentheses to complete the code. (You have to add the clickThrough.onPress = function() part by hand, however.)
Figure 3. Adding code to automate and track clickthroughs
Switch to the first frame of the Links and Descriptions layer. Go to the set of variables beginning with exit1 and add the following code:
exit1 = "http://www.macromedia.com/software/flash/flash_ad_kit/"; exit1window = "_blank"; exit1windowFeatures = ""; exit1name = "ClickThrough1"; exit1desc = "exit click from the background button";
Adding unique events to track what happens in the ad is easy. One example is to add an event to the tab buttons to find out if viewers click to see the video or sign up for a free sample of the product:
Place the following code on the Script layer in Frame 11:
tab2.onRelease = function() {
_root.conduit.event(1);
gotoAndPlay("tab2");
};
Switch to the first frame of the Links and Descriptions layer. Go to the set of variables beginning with "event1" and add the following code:
event1name = "mainToVideo"; event1desc = "click from the main tab to the video screen";
In Line 10 of the Links and Descriptions layer, remove the forward slashes from the line of code so it looks like this:
conduit_debug = true;
This turns on a debugger so you can test that your events are working.
Adding timers to the tab buttons so you know how long a viewer watches each screen is also a straightforward procedure. This can provide useful information to determine how well an ad performs in the real world:
Place the following code in Frame 19 on the Script layer:
_root.conduit.startTimer(1);
In order to stop the timer and get a proper value for time spent on the video screen, add stopTimer functions to the tab buttons that switch to the other screens. In Frame 19 of the Script layer, add the following code:
tab1.onRelease = function() {
_root.conduit.stopTimer(1);
gotoAndPlay("tab1");
}
tab3.onRelease = function() {
_root.conduit.stopTimer(1);
gotoAndPlay("tab3");
}
Switch to the first frame of the Links and Descriptions layer. Go to the set of variables beginning with "timer1" and add the following code:
timer1name = "videoTime"; timer1desc = "time spent in the video screen";
The ad will now send tracking information to the ad server about the time spent on the video screen.
You can add further events and timers to each part of the ad. For example, each input text box could contain an event so that you could track where users stop filling out the form. This information could help you improve the ad's effectiveness.
Once you set up the base ad document (goAwayAd.fla), adding streaming video requires creating another Flash movie, adding media components to display the video stream, and defining tracking events.
The video stream is contained in an external, non–Flash Ad Kit template Flash movie. Using a Flash Ad Kit template Flash movie to create the video stream SWF would unnecessarily add extra file size to the movie because the template always contains ActionScript to communicate with the ad server. Only the base SWF needs to contain this code, not the external Flash movie:
Select Window > Development Panels > Components to open the Components panel (see Figure 4).
Figure 4. Taking advantage of the MediaController and MediaDisplay components
By default, the MediaDisplay component plays back the video stream at the dimensions it receives the video. This is fine if you have properly sized video but it's often necessary to exert more control over the dimensions of the video. For example, the video stream could be a larger size than the playback area, so make it smaller at runtime:
In some cases you will not want to allow your ad viewers to control the playback of the video. In this video ad, however, you want to give your audience the ability to pause, move around the streaming video timeline, and control the playback volume:
Figure 5. Selecting the path to the videoDisplay instance
Displaying streaming video in the MediaDisplay component requires you to add ActionScript to your Flash movie to associate the display with the proper video stream:
Paste the code below into the ActionScript layer. The video stream you're using in this article is provided by an XML file. The FVSS changes where the file is located depending on server traffic and load, so your video is always presented rapidly and at the highest possible quality. This code retrieves XML data from the server, pulls a video stream URL out of the XML data, and provides the URL to the component for video playback:
videoLink = "http://videoLink";
var vs_xml:XML = new XML();
vs_xml["media"] = this;
vs_xml.onLoad = function(success:Boolean) {
if (success) {
var appURL:String = this.firstChild.firstChild.nextSibling.firstChild.nodeValue;
var streamName:String = this.firstChild.firstChild.firstChild.nodeValue;
videoDisplay.setMedia(appURL+"/"+streamName, "FLV");
} else {
trace("Error!");
}
};
vs_xml.load(videoLink);
Change the videoLink variable to the direct URL provided by your Flash streaming service provider. To access the sample video stream used by this article paste the following link (including the quotes):
"http://flash.vitalstream.com/flashgen.cgi?sname=go_away_spray.flv&aname=fvss_vitalstream_com/_definst_"
The Flash Ad Kit templates automate the loading of external movies from associated ad servers. In this article the Flash ad loads the video movie into an empty movie clip and displays the video. A best practice is always to load external movies into movie clips in Flash; it is not a good practice to load movies into levels:
In order for the video movie to load correctly within the Flash Ad Kit template movie, you need to modify specific variables in the Links and Descriptions layer:
Change the movie1target variable to _root.empty (see Figure 6).
Figure 6. Changing the movie variables in the Links and Descriptions layer
The movie1name and movie1desc variables track the loading of the movie. The movie1name variable, which cannot contain any spaces, is used in ad reports. The movie1desc variable, which can contain spaces, is only a reference description for people involved with the ad serving.
Once you have completed the Flash ad and successfully added the video movie, use the Flash Ad Kit panel to preview the ad as it will appear on an HTML page and publish the ad in a format ready to use with DART Motif.
You create two separate files with the Flash Ad Kit. The first is an MTA file that is the project file for the ad. The MTA file contains all the ad assets, including FLAs, SWFs, GIFs, JPEGs, XML files, and any other files necessary for your ad to work properly. The second file is an MTF file, which is a compressed file containing all the ad assets in your MTA file. The ad server decompresses the MTF file and serves the ad to publishers.
In order to create an MTA file:
Save the new file as goAwayAdLearn.mta (see Figure 7).
Figure 7. The Flash Ad Kit panel awaiting linked assets
An alternate image needs to be selected for your Flash ad in case a web user does not have Flash installed. The Flash Ad Kit will not allow you to publish an MTF file without this information because publisher sites always require an alternate image for Flash ads. Click the folder icon next to Alt. Image and select the appropriate image, in this case staticAd.jpg (see Figure 8).
Figure 8. Selecting an alternate image file
Because the main ad loads an external video movie upon user selection, you need to create a child asset in the Flash Ad Kit panel and associate the video movie with it:
Click OK to return to the main Flash Ad Kit panel screen (see Figure 9).
Figure 9. Defining a child asset in the Flash Ad Kit panel
The Flash Ad Kit creates a fully functional preview of the ad in any HTML document as long as the proper HTML tag is included. All you need to do is place <motif></motif> tags within the body of the HTML document. A simple HTML page called goAway.htm has been created with the <motif></motif> tags already placed in the body of the HTML page. You can add the tags to any HTML document to preview proper ad placement and functionality:
A dialog box appears requesting the location of the HTML document for previewing. Click the folder icon and locate goAway.htm (see Figure 10).
Figure 10. Choosing a preview HTML page for the ad
Note: The preview file from DoubleClick contains JavaScript and XML in an HTML page to display the ad. The preview file is placed in a Preview folder where the MTA file is located. Proper preview in Windows requires Internet Explorer 5.5 or later. Mac OS users should have Internet Explorer 5 or later. For more information, read the Flash Ad Kit Release Notes.
Once you preview the ad and make sure it functions properly, package the ad into an MTF file for use on the DART Motif ad servers. The MTF file is a compressed ZIP file with all of the associated ad assets (SWFs, child SWFs, JPEGs, GIFs, XML, and so on). Using Preview creates an MTF file. If you haven't used Preview to review your ad, you can also create an MTF file by choosing File > Package MTF in the Flash Ad Kit panel.
After upload the MTF file, the DART Motif ad server uncompresses the MTF file and makes the Motif ad fully functional. Your ad is now ready to be sent to publishers' sites to be viewed by consumers.
Using the Flash Ad Kit and media components makes it easy and efficient to create rich interactive ads with high-impact video. Advertisers benefit from the ability to gain a wide range of useful analytic detail on the effectiveness of their ads, and viewers receive a better marketing message. Designers and developers gain ease of use from the Flash Ad Kit, gaining more time to spend on the look and feel of the ad rather than on repetitive programming tasks.