F2fEnabler is the enabler for creatives to be served in a Flash environment.
F2fEnabler.getInstance().counter("my custom counter");
import com.google.ads.studio.F2fEnabler;
// All the event types are accessed through StudioEvent.
import com.google.ads.studio.events.StudioEvent;
// Get a reference to the F2fEnabler;
var enabler:F2fEnabler = F2fEnabler.getInstance();
// Initialize the F2fEnabler! The "this" keyword refers to the base
// display object.
enabler.init(this);
var exitHandler:Function = function(event:StudioEvent):void {
// This will output the value of StudioEvent.EXIT which is
// "exit".
trace(event.type);
};
enabler.addEventListener(StudioEvent.EXIT, exitHandler);
Inherited Fields
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);
| ||||||
F2F_CUSTOM_EVENT | com.google.ads.studio.events.StudioEvent | Dispatched via API call to notify the IMA SDK, so that the IMA SDK can handle the event. The properties of the event object have the following values:
| ||||||
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);
|
Static Methods
F2fEnabler.getInstance()
:
F2fEnablerGets the singleton instance of F2fEnabler.
Instance Methods
Defined in: com.google.ads.studio:AbstractEnabler
close()
:
voidCloses 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)
:
voidCloses 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()
:
voidClips 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)
:
voidTracks 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)
:
voidDisplays the companion asset.
var showClickHandler:Function = function(event:MouseEvent):void {
enabler.displayCompanion();
};
showButton.addEventListener(MouseEvent.CLICK, showClickHandler);
exit(exitId:String, url:String=null)
:
voidOpens 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()
:
voidExits Flash's native fullscreen mode.
var closeFsClickHandler:Function = function(event:MouseEvent):void {
enabler.exitFullScreen();
};
closeFsButton.addEventListener(MouseEvent.CLICK, closeFsClickHandler);
exitQueryString(id:String, queryString:String)
:
voidOpens 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)
:
voidUnclips 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()
:
voidThis 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()
:
intGets the DART ad ID.
enabler.exitQueryString("Background Exit", enabler.getDartAdId());
getDartCreativeId()
:
intGets the DART creative ID.
enabler.exitQueryString("Background Exit", enabler.getDartCreativeId());
getDartPageId()
:
intGets the DART page ID.
enabler.exitQueryString("Background Exit", enabler.getDartPageId());
getDartRenderingId()
:
intGets the DART rendering ID.
enabler.exitQueryString(
"Background Exit",
enabler.getDartRenderingId());
getDartSiteId()
:
intGets the DART site ID.
enabler.exitQueryString("Background Exit", enabler.getDartSiteId());
getDartSiteName()
:
StringGets the DART site name.
enabler.exitQueryString("Background Exit", enabler.getDartSiteName());
getDomainWhiteList()
:
ArrayReturns the whitelisted domains for Studio.
getElapsedTime()
:
NumberRetrieves 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)
:
ObjectRetrieves 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)
:
intRetrieves a creative parameter as a typed integer.
var intParam:Number = enabler.getParameterAsInteger("intParam");
getStreamingVideoUrl(originalFilename:String)
:
StringGets 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)
:
StringGets 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()
:
intGets the user's bandwidth according to DART bandwidth codes.
var userBandwidth:Number = enabler.getUserBandwidth();
getUserCountry()
:
StringGets the two-letter string representation of the user's country, as defined by iso-3166-1 alpha 2.
var userCountry:String = enabler.getUserCountry();
getUserDMACode()
:
StringReturns a DART representation of the user's Nielsen Designated Market Area.
var userDmaCode:String = enabler.getUserDMACode();
getUserState()
:
StringGets the two letter string representation of the user's state or province.
var userState:String = enabler.getUserState();
getUserZipCode()
:
StringGets the user's zip code (for users in the United States, U.S. Territories, and Canada).
var userZipCode:String = enabler.getUserZipCode();
getVolume()
:
NumberReturns 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()
:
BooleanAccessor to find out if the ad has started.
hasUserInteracted()
:
BooleanIndicates 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)
:
voidInitializes the Enabler.
isFlashFullScreenSupported()
:
BooleanIndicates whether or not the system is compatible and enabled to launch into FullScreen mode.
if (!enabler.isFlashFullScreenSupported()) {
openFsButton.visible = false;
closeFsButton.visible = false;
}
isInFullScreen()
:
BooleanReturns if the ad is currently in full screen mode.
isInitialized()
:
BooleanIndicates 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()
:
BooleanIndicates 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)
:
voidLaunches 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()
:
voidMutes all video controllers.
var muteAllClickHandler:Function = function(event:MouseEvent):void {
enabler.muteAllVideos();
};
muteAllButton.addEventListener(MouseEvent.CLICK, muteAllClickHandler);
pageHasLoaded()
:
BooleanIndicates 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)
:
voidAllows 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)
:
voidCounts 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)
:
voidCounts 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()
:
voidRecords 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)
:
voidSets 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)
:
voidSets the default full screen stage align. Useful when using full screen buttons where you don't explicitly invoke #launchFullScreen.
setDefaultFullScreenScaleMode(scaleMode:String)
:
voidSets the default full screen scale mode. Useful when using full screen buttons where you don't explicitly invoke #launchFullScreen.
setDuration(duration:Number)
:
voidUpdates 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)
:
voidUpdates 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)
:
voidUpdates 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)
:
voidSets the default full screen source rectangle. Useful when using full screen buttons where you don't explicitly invoke #launchFullScreen.
setGlobalData(key:String, data:Object)
:
voidSets data that can be accessed between classes and SWFs.
setHint(name:String, value:Object=null)
:
AbstractEnablerSets a predefined hint to be parsed on upload of the creative.
setLinear(linear:Boolean)
:
voidUpdates 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)
:
voidUpdates 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)
:
voidUpdates and sets the current volume of the ad. This is currently only supported for linear in-stream creatives.
startTimer(timerId:String)
:
voidStarts an event timer.
var mainPanelMouseoverHandler:Function = function(
event:MouseEvent):void {
enabler.startTimer("Roll Button Timer");
};
mainPanel.addEventListener(
MouseEvent.MOUSE_OVER,
mainPanelMouseoverHandler);
stopAllVideos()
:
voidStops all video controllers.
var stopAllClickHandler:Function = function(event:MouseEvent):void {
enabler.stopAllVideos();
};
stopAllButton.addEventListener(MouseEvent.CLICK, stopAllClickHandler);
stopTimer(timerId:String)
:
voidStops an event timer.
var mainPanelMouseoutHandler:Function = function(
event:MouseEvent):void {
enabler.stopTimer("Main Panel Timer");
};
mainPanel.addEventListener(
MouseEvent.MOUSE_OUT,
mainPanelMouseoutHandler);
waitForLoad()
:
voidThis 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
}
Defined in com.google.ads.studio:F2fEnabler
dispatchCustomEvent(customEventName:String)
:
voidBubbles up an event through the IMA SDK so that publisher can listen to events dispatched from the ad.
dispatchEvent(event:flash.events:Event)
:
Booleaninit(baseDisplayObject:flash.display:DisplayObject)
:
voidInitializes the Enabler.
isInPreview()
:
BooleanReturns if the enabler is currently running in a preview environment.
isRunningLocally()
:
BooleanlogVideoEvent(type:String, videoName:String, eventId:String, primary:Boolean=false)
:
void