AbstractEnabler serves as the base class that HTML and F2F Enablers implement. This class must be present and initialized in the main (parent) asset of every DoubleClick Rich Media creative. It is the bridge between the creative and the ad delivery platform, and takes care of setting up environment variables, making tracking requests, and dispatching important events based on events taking place in the external environment. The Enabler is a non-DisplayObject class. Because of this, a reference to the stage must be passed into the class during initialization. This enables the Enabler to pick up and process the flashVars. Note that Multiple Event Tracking triplet is referred to as MET.
Constants
Name | Value | Description |
---|---|---|
BANDWIDTH_CABLE | 3 | A possible value returned from getUserBandwidth which represents a cable bandwidth. |
BANDWIDTH_DIALUP | 1 | A possible value returned from getUserBandwidth which represents a dialup bandwidth. |
BANDWIDTH_DSL | 2 | A possible value returned from getUserBandwidth which represents a DSL bandwidth. |
BANDWIDTH_T1 | 4 | A possible value returned from getUserBandwidth which represents a T1 or greater bandwidth. |
BANDWIDTH_UNKNOWN | 0 | A possible value returned from getUserBandwidth which represents an unknown or undetectable bandwidth. |
VIDEO_IDENTIFIER_DUMMY_PREFIX | configurable_vri_ | Prefix that configurable video player uses for unique dummy reporting identifiers. A random ID will be appended in practice. |
Events
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
COLLAPSE_COMPLETE | com.google.ads.studio.events.StudioEvent | Dispatched when a collapse is completed. import com.google.ads.studio.events.StudioEvent; var collapseCompleteHandler:Function = function(event:StudioEvent):void { trace("Collapse completed."); }; enabler.addEventListener( StudioEvent.COLLAPSE_COMPLETE, collapseCompleteHandler); | ||||||
EXIT | com.google.ads.studio.events.StudioEvent | Dispatched when an exit is performed. The properties of the event object have the following values:
import com.google.ads.studio.events.StudioEvent; var exitHandler:Function = function(event:StudioEvent):void { trace(event.id + " exit clicked."); }; enabler.addEventListener(StudioEvent.EXIT, exitHandler); | ||||||
EXPAND | com.google.ads.studio.events.StudioEvent | Dispatched when an expansion occurs. import com.google.ads.studio.events.StudioEvent; var expandHandler:Function = function(event:StudioEvent):void { trace("Ad expanded."); }; enabler.addEventListener(StudioEvent.EXPAND, expandHandler); | ||||||
FULL_SCREEN | com.google.ads.studio.events.StudioEvent | Dispatched when the creative goes into full screen mode. import com.google.ads.studio.events.StudioEvent; var fsOpenHandler:Function = function(event:StudioEvent):void { trace("Fullscreen opened."); }; enabler.addEventListener(StudioEvent.FULL_SCREEN, fsOpenHandler); | ||||||
FULL_SCREEN_EXIT | com.google.ads.studio.events.StudioEvent | Dispatched when the creative returns from full screen mode. import com.google.ads.studio.events.StudioEvent; var fsCloseHandler:Function = function(event:StudioEvent):void { trace("Fullscreen closed."); }; enabler.addEventListener(StudioEvent.FULL_SCREEN_EXIT, fsCloseHandler); | ||||||
INTERACTION | com.google.ads.studio.events.StudioEvent | Dispatched when a user interaction has been detected. import com.google.ads.studio.events.StudioEvent; var enablerInteractionHandler:Function = function( event:StudioEvent):void { trace("User interacted."); }; enabler.addEventListener( StudioEvent.INTERACTION, enablerInteractionHandler); | ||||||
PAGE_LOADED | com.google.ads.studio.events.StudioEvent | Dispatched when the containing page has completed loading. import com.google.ads.studio.events.StudioEvent; var pageLoadedHandler:Function = function(event:StudioEvent):void { trace("Page loaded."); }; enabler.addEventListener(StudioEvent.PAGE_LOADED, pageLoadedHandler); | ||||||
STAGE_MOUSE_OUT | com.google.ads.studio.events.StudioEvent | Dispatched when the mouse rolls off of the creative stage. import com.google.ads.studio.events.StudioEvent; var stageMouseOutHandler:Function = function(event:StudioEvent):void { trace("Mouse out."); }; enabler.addEventListener( StudioEvent.STAGE_MOUSE_OUT, stageMouseOutHandler); | ||||||
STAGE_MOUSE_OVER | com.google.ads.studio.events.StudioEvent | Dispatched when the mouse rolls onto the creative stage. import com.google.ads.studio.events.StudioEvent; var stageMouseOverHandler:Function = function(event:StudioEvent):void { trace("Mouse over."); }; enabler.addEventListener( StudioEvent.STAGE_MOUSE_OVER, stageMouseOverHandler); |
Instance Methods
Defined in com.google.ads.studio:AbstractEnabler
close()
:
void
Closes floating and Pop-up creative types. If it is an expanding creative, close acts as a proxy to collapse.
var closeClickHandler:Function = function(event:MouseEvent):void { enabler.close(); }; closeButton.addEventListener(MouseEvent.CLICK, closeClickHandler);
closeCompanion(assetName:String=null)
:
void
Closes the companion asset for floating, reminder and Pop-up creative types.
var closeClickHandler:Function = function(event:MouseEvent):void { enabler.closeCompanion(); }; closeButton.addEventListener(MouseEvent.CLICK, closeClickHandler);
collapse()
:
void
Clips the container of the Flash asset from the expanded dimensions to the collapsed dimensions. This function is only applicable for expandable ad formats.
var collapseClickHandler:Function = function(event:MouseEvent):void { enabler.collapse(); }; collapseButton.addEventListener(MouseEvent.CLICK, collapseClickHandler);
counter(eventId:String, isCumulative:Boolean=false)
:
void
Tracks a counter event.
var closeClickHandler:Function = function(event:MouseEvent):void { enabler.counter("Close Button Counter"); enabler.close(); }; collapseButton.addEventListener(MouseEvent.CLICK, closeClickHandler);
displayCompanion(assetName:String=null)
:
void
Displays the companion asset.
var showClickHandler:Function = function(event:MouseEvent):void { enabler.displayCompanion(); }; showButton.addEventListener(MouseEvent.CLICK, showClickHandler);
exit(exitId:String, url:String=null)
:
void
Opens a new window with the URL as identified by the given exit ID.
var exitClickHandler:Function = function(event:MouseEvent):void { enabler.exit("Background Exit"); }; customExitButton.addEventListener(MouseEvent.CLICK, exitClickHandler);
exitFullScreen()
:
void
Exits Flash's native fullscreen mode.
var closeFsClickHandler:Function = function(event:MouseEvent):void { enabler.exitFullScreen(); }; closeFsButton.addEventListener(MouseEvent.CLICK, closeFsClickHandler);
exitQueryString(id:String, queryString:String)
:
void
Opens a new window with the URL as identified by the given exit id. The queryString is appended to the URL.
var exitClickHandler:Function = function(event:MouseEvent):void { enabler.exitQueryString("Background Exit", "id=doubleclick"); }; customExitButton.addEventListener(MouseEvent.CLICK, exitClickHandler);
expand(disableTracking:Boolean=false)
:
void
Unclips the container of the Flash asset from the collapsed dimensions to the expanded dimensions. This function is only applicable for expandable ad formats.
var expandClickHandler:Function = function(event:MouseEvent):void { enabler.expand(); }; expandButton.addEventListener(MouseEvent.CLICK, expandClickHandler);
finishedLoad()
:
void
This method decrements the count of assets that are currently loading. It should be called when you are finished loading an asset. See Enabler.waitForLoad() for an example.
getCustomParameter(variableName:String)
Retrieves a custom parameter.
var stringParam:String = enabler.getCustomParameter("stringParam");
getDartAdId()
:
int
Gets the DART ad ID.
enabler.exitQueryString("Background Exit", enabler.getDartAdId());
getDartCreativeId()
:
int
Gets the DART creative ID.
enabler.exitQueryString("Background Exit", enabler.getDartCreativeId());
getDartPageId()
:
int
Gets the DART page ID.
enabler.exitQueryString("Background Exit", enabler.getDartPageId());
getDartRenderingId()
:
int
Gets the DART rendering ID.
enabler.exitQueryString( "Background Exit", enabler.getDartRenderingId());
getDartSiteId()
:
int
Gets the DART site ID.
enabler.exitQueryString("Background Exit", enabler.getDartSiteId());
getDartSiteName()
:
String
Gets the DART site name.
enabler.exitQueryString("Background Exit", enabler.getDartSiteName());
getDomainWhiteList()
:
Array
Returns the whitelisted domains for Studio.
getElapsedTime()
:
Number
Retrieves the amount of time that has elapsed in the ad if supported by the environment. This is currently only supported for linear in-stream creatives.
getFilename(originalFilename:String)
:
String
DEPRECATED
Gets the runtime file name given the original compile-time file name. The original file name may have been mapped to a newer file name.var fileName:String = enabler.getFilename( "AS3_300x250_test_snippets.swf");
getGlobalData(key:String)
:
Object
Retrieves data from the shared data object for sharing between classes and SWFs.
getParameter(variableName:String)
Retrieves a creative parameter which the user can pass via queryString URL. This is the public-facing version of getAdParameter, and does some pre-filtering based on nulls and empties.
var stringParam:String = enabler.getParameter("stringParam");
getParameterAsInteger(name:String)
:
int
Retrieves a creative parameter as a typed integer.
var intParam:Number = enabler.getParameterAsInteger("intParam");
getStreamingVideoUrl(originalFilename:String)
:
String
Gets the DART-hosted streaming URL to be used at runtime given an original child asset file name.
var videoUrl:String = enabler.getStreamingVideoUrl("video.flv");
getUrl(filenameOrHttpUrl:String, httpsUrl:String=null)
:
String
Gets the runtime URL given the original compile-time filename.
var url:String = enabler.getUrl("AS3_300x250_test_snippets.swf");
getUserAreaCode()
:
String
DEPRECATED
Returns the user's area code.var userAreaCode:String = enabler.getUserAreaCode();
getUserBandwidth()
:
int
Gets the user's bandwidth according to DART bandwidth codes.
var userBandwidth:Number = enabler.getUserBandwidth();
getUserCountry()
:
String
Gets the two-letter string representation of the user's country, as defined by iso-3166-1 alpha 2.
var userCountry:String = enabler.getUserCountry();
getUserDMACode()
:
String
Returns a DART representation of the user's Nielsen Designated Market Area.
var userDmaCode:String = enabler.getUserDMACode();
getUserState()
:
String
Gets the two letter string representation of the user's state or province.
var userState:String = enabler.getUserState();
getUserZipCode()
:
String
Gets the user's zip code (for users in the United States, U.S. Territories, and Canada).
var userZipCode:String = enabler.getUserZipCode();
getVolume()
:
Number
Returns the volume that the environment requested the ad be set to if supported. Values of -1 indicate that there is no requested volume. This is currently only supported for linear in-stream creatives.
hasStarted()
:
Boolean
Accessor to find out if the ad has started.
hasUserInteracted()
:
Boolean
Indicates whether or not a user has interacted with the ad. If the user moused over the ad, we assume that the user interacted with it.
init(baseDisplayObject:flash.display:DisplayObject)
:
void
Initializes the Enabler.
isFlashFullScreenSupported()
:
Boolean
Indicates whether or not the system is compatible and enabled to launch into FullScreen mode.
if (!enabler.isFlashFullScreenSupported()) { openFsButton.visible = false; closeFsButton.visible = false; }
isInFullScreen()
:
Boolean
Returns if the ad is currently in full screen mode.
isInitialized()
:
Boolean
Indicates whether or not the Enabler has initialized. This method is generally used by other Studio components.
import com.google.ads.studio.events.StudioEvent; var enablerInitHandler:Function = function(event:StudioEvent):void { trace("Enabler initialized."); }; if (enabler.isInitialized()) { trace("Enabler initialized."); } else { trace("Enabler not yet initialized."); enabler.addEventListener(StudioEvent.INIT, enablerInitHandler); }
isRunningLocally()
:
Boolean
Indicates whether or not the creative is running locally or off the ad serving platform.
if (enabler.isRunningLocally()) { trace("Flash is running locally."); }
launchFullScreen(scaleMode:String=null, align:String=null, sourceRectangle:flash.geom:Rectangle=null)
:
void
Launches the creative in Flash's native fullscreen mode. Stage scale mode and align get reset to the original values when the creative exits fullscreen.
var openFsClickHandler:Function = function(event:MouseEvent):void { enabler.launchFullScreen(); }; openFsButton.addEventListener(MouseEvent.CLICK, openFsClickHandler);
muteAllVideos()
:
void
Mutes all video controllers.
var muteAllClickHandler:Function = function(event:MouseEvent):void { enabler.muteAllVideos(); }; muteAllButton.addEventListener(MouseEvent.CLICK, muteAllClickHandler);
pageHasLoaded()
:
Boolean
Indicates whether or not the host page has loaded.
import com.google.ads.studio.events.StudioEvent; var pageLoadedHandler:Function = function(event:StudioEvent):void { trace("Page loaded."); }; if (enabler.pageHasLoaded()) { trace("Page loaded."); } else { trace("Page not yet loaded."); enabler.addEventListener(StudioEvent.PAGE_LOADED, pageLoadedHandler); }
registerChargeableEventName(eventName:String)
:
void
Allows a creative to specify the event they wish to be charged on.
reportCustomClickVariable(postString:String)
:
void
DEPRECATED
This tracks a click against the string parameter. See: reportCustomVariableCount1(customString:String)reportCustomImpressionVariable(postString:String)
:
void
DEPRECATED
Tracks an impression against the string parameter. See: reportCustomVariableCount1(postString:String)reportCustomVariableCount1(customString:String)
:
void
Counts instances of the string parameter, aggregated as Custom Variable Count 1 in reports. The string must meet the following criteria:
- The string cannot exceed 100 characters
- The string must only contain Latin characters (0-9, Aa-Zz)
- The string must NOT contain any personally identifiable information such as name, email address, phone number, health info, financial info, etc.
var siteName:String = enabler.getDartSiteName(); enabler.reportCustomVariableCount1("Site Name: " + siteName);
reportCustomVariableCount2(customString:String)
:
void
Counts instances of the string parameter, aggregated as Custom Variable Count 2 in reports. The string must meet the following criteria:
- The string cannot exceed 100 characters
- The string must NOT contain any personally identifiable information such as name, email address, phone number, health info, financial info, etc.
var siteName:String = enabler.getDartSiteName(); var customReportClickHandler:Function = function( event:MouseEvent):void { enabler.reportCustomVariableCount2("Site Name: " + siteName); }; customReportButton.addEventListener( MouseEvent.CLICK, customReportClickHandler);
reportManualClose()
:
void
Records a manual closing of a Floating, Pop-up, Expanding, In-Page with Pop-up, or In-Page with Floating ad.
var closeClickHandler:Function = function(event:MouseEvent):void { enabler.reportManualClose(); enabler.close(); }; closeButton.addEventListener(MouseEvent.CLICK, closeClickHandler);
setClipRegion(clipRect:flash.geom:Rectangle)
:
void
Sets the region of the ad that should still be visible when the ad is collapsed. Only used if the environment supports this. The function is considered internal and shouldn't be called directly. Use the expanding component instead.
setDefaultFullScreenAlign(align:String)
:
void
Sets the default full screen stage align. Useful when using full screen buttons where you don't explicitly invoke #launchFullScreen.
setDefaultFullScreenScaleMode(scaleMode:String)
:
void
Sets the default full screen scale mode. Useful when using full screen buttons where you don't explicitly invoke #launchFullScreen.
setDuration(duration:Number)
:
void
Updates and sets the total duration of the ad if supported by the environment. This is currently only supported for linear in-stream creatives.
setElapsedTime(elapsedTime:Number)
:
void
Updates and reports the amount of time that has elapsed in the ad if supported by the environment. This is currently only supported for linear in-stream creatives.
setExpanded(expanded:Boolean)
:
void
Updates and reports the expanded state of the ad if supported by the environment. This method is considered internal and shouldn't be called directly. Use the expanding component instead.
setFullScreenSourceRectangle(sourceRectangle:flash.geom:Rectangle)
:
void
Sets the default full screen source rectangle. Useful when using full screen buttons where you don't explicitly invoke #launchFullScreen.
setGlobalData(key:String, data:Object)
:
void
Sets data that can be accessed between classes and SWFs.
setHint(name:String, value:Object=null)
:
AbstractEnabler
Sets a predefined hint to be parsed on upload of the creative.
setLinear(linear:Boolean)
:
void
Updates and reports the linear state of the ad if supported by the environment. This should only be used by VPAID ads that are initially non-linear.
setSkippable(skippable:Boolean)
:
void
Updates and reports the skippable state of the ad if supported by the environment. This is currently only supported for linear in-stream creatives.
setVolume(volume:Number)
:
void
Updates and sets the current volume of the ad. This is currently only supported for linear in-stream creatives.
startTimer(timerId:String)
:
void
Starts an event timer.
var mainPanelMouseoverHandler:Function = function( event:MouseEvent):void { enabler.startTimer("Roll Button Timer"); }; mainPanel.addEventListener( MouseEvent.MOUSE_OVER, mainPanelMouseoverHandler);
stopAllVideos()
:
void
Stops all video controllers.
var stopAllClickHandler:Function = function(event:MouseEvent):void { enabler.stopAllVideos(); }; stopAllButton.addEventListener(MouseEvent.CLICK, stopAllClickHandler);
stopTimer(timerId:String)
:
void
Stops an event timer.
var mainPanelMouseoutHandler:Function = function( event:MouseEvent):void { enabler.stopTimer("Main Panel Timer"); }; mainPanel.addEventListener( MouseEvent.MOUSE_OUT, mainPanelMouseoutHandler);
waitForLoad()
:
void
This method increments the count of assets that are currently loading. It should be called right before you begin loading an asset necessary for the initial display of the creative. When the asset is finished loading, a corresponding call to finishedLoad() must be made.
enabler.waitForLoad(); var urlRequest:URLRequest = new URLRequest(URL); var urlLoader:URLLoader = new URLLoader(); urlLoader.addEventListener(Event.COMPLETE, urlLoadedHandler); urlLoader.addEventListener(IOErrorEvent.IO_ERROR, urlErrorHandler); urlLoader.load(urlRequest); function urlLoadedHandler(event:Event):void { enabler.finishedLoad(); // Use loaded asset } function urlErrorHandler(event:Event):void { enabler.finishedLoad(); // Handle error }