Layouts allows designers to define a layout which can be customized by Studio users.
import com.google.ads.studio.layouts.Layouts;
var image:Image = new Image();
var tooltip:ToolTip = new ToolTip();
image.addChild(tooltip);
// Register image at the "root" level of the layout.
Layouts.getInstance().register("top image", image);
// Register tooltip nested inside of image.
Layouts.getInstance().register("tooltip", tooltip, image);
Constants
| Name | Value | Description |
|---|---|---|
ARRAY_ADD_TAG | ConfigurableArrayAdd | |
ARRAY_DISPOSE_TAG | ConfigurableArrayDispose | Layouts meta-tags |
ARRAY_REMOVE_TAG | ConfigurableArrayRemove | |
ASSET_ID_TAG | assetId | |
CHANGE_VALUE_FUNCTION | changeValue | |
FIELD_META_TAG | Configurable | |
GWT_INVOKE_FUNCTION | window.layoutsPreviewManager.invokeLayoutGwtFunction | |
HIDE_NODE_FUNCTION | hideNode | |
LAYOUTS_PREVIEW_ENVIRONMENT | layoutsPreviewEnv | |
PLAYER_TYPE_ACTIVEX | ActiveX | |
PLAYER_TYPE_PLUGIN | PlugIn | |
REDRAW_META_TAG | ConfigurableUpdate | |
SAFE_LAYOUTS_CONFIG_INDICATOR | \x3clayout | |
SET_ACTIVE_SCENE_FUNCTION | setActiveScene | |
SHOW_NODE_FUNCTION | showNode | |
TYPE_BOOLEAN | bool | |
TYPE_COLOR | color | |
TYPE_DOUBLE | double | |
TYPE_LONG | long | |
VALUE_FLASHVARS_NAME | layoutsConfig | The flashvars variable name for the values. |
VIDEO_REPORTING_IDENTIFIER | videoReportingIdentifier | |
instance | | The singleton instance of the Layouts class. |
Properties
| Name | Type | Description | Default |
|---|---|---|---|
detachedRootsToChildren | Dictionary | | |
scenesMap | Object | unknown |
Events
| Name | Type | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
FAIL | com.google.ads.studio.events.StudioEvent | Dispatched when the component has failed to initialize. | ||||||||
INIT | com.google.ads.studio.events.StudioEvent | Dispatched when the component has initialized.
This event may fire almost immediately after component construction. To
ensure capturing the initialized state please refer to the example:
// Note the variable component refers to the component instance.
import com.google.ads.studio.events.StudioEvent;
var initializedHandler:Function = function(
event:StudioEvent = null):void {
trace("The component initialized!");
};
if (component.isInitialized()) {
initializedHandler();
} else {
component.addEventListener(StudioEvent.INIT, initializedHandler);
}
| ||||||||
SCENE_ACTIVE | com.google.ads.studio.events.StudioEvent | Dispatched just before the Layouts component activates a scene. The properties of the event object have the following values:
import com.google.ads.studio.events.StudioEvent;
var sceneChangeHandler:Function = function(event:StudioEvent):void {
if (event.isDynamic) {
// Make sure the scene's parent object is on display.
var sceneParentObject:DisplayObject = event.parent;
clearStage();
addChild(sceneParentObject);
trace("A dynamic scene is now active:" + event.sceneName);
} else {
trace("A scene is now active:" + event.sceneName);
}
};
Layouts.getInstance().addEventListener(
StudioEvent.SCENE_ACTIVE,
sceneChangeHandler);
| ||||||||
UPDATE | com.google.ads.studio.events.StudioEvent | Dispatched by the registered display object when it has been updated by layouts.
import com.google.ads.studio.events.StudioEvent;
var imageUpdateHandler:Function = function(event:StudioEvent):void {
trace("Image was updated by layouts.");
};
var image:Image = new Image();
Layouts.getInstance().register("top image", image);
image.addEventListener(
StudioEvent.UPDATE,
imageUpdateHandler);
|
Static Methods
Layouts.getInstance()
:
LayoutsReturns the singleton instance of the Layouts class.
Instance Methods
Defined in: com.google.ads.studio:EnabledComponent
getEnabler()
:
ObjectisInitialized()
:
BooleanReturns whether the component has initialized.
Defined in com.google.ads.studio.layouts:Layouts
addArrayValues(id:String, arrayName:String, valueContainers:Array, classNames:Array=null)
:
intAdd an array element value object for a configurable display object.
addTestArrayValues(id:String, arrayName:String, valueContainers:Array, classNames:Array=null)
:
intFor testing, add an array element value object for a configurable display object.
import com.google.ads.studio.layouts.Layouts;
layouts.addTestArrayValues("left gallery", "images",
[{imageTitle:"doggy",
description:"running",
url:"dog1.jpg"},
{imageTitle:"kitty",
description:"sleeping",
url:"cat1.jpg"}],
["Image", "Image"]);
changeFillerValue(registrationId:String, value:Object)
:
voidChange the value of a configurable display object in the filler. Sets the value on the registered object if found, but does not call any ConfigurableUpdate.
import com.google.ads.studio.layouts.Layouts;
// Register the object with layouts.
var layouts:Layouts = Layouts.getInstance();
layouts.register("video", video, "Video");
// ...
layouts.changeFillerValue(layouts.getRegistrationId(video),
{videoUrl: "www.google.com"});
counter(displayObject:flash.display:DisplayObject, eventId:String, isCumulative:Boolean=false)
:
voidTracks a counter event for a registered display object in the layout. Use this function if you want to allow tracking different counters for multiple instances of the same type.
var expandClickHandler:Function = function(event:MouseEvent):void {
layouts.counter(event.target, "Expand Counter");
images[i].expand();
};
for each (var button:Sprite in expandButtons) {
button.addEventListener(MouseEvent.CLICK, expandClickHandler);
}
exit(displayObject:flash.display:DisplayObject, exitId:String)
:
voidTracks an exit event for a registered display object in the layout.
var linkClickHandler:Function = function(event:MouseEvent):void {
layouts.exit(event.target, "Click Exit");
};
for each (var link:Sprite in links) {
link.addEventListener(MouseEvent.CLICK, linkClickHandler);
}
getDisplayObject(id:String)
:
DisplayObjectGets the display object that was registered by the given id.
getDto(id:String)
:
DisplayObjectDtoGets the {
getRegistrationId(displayObjectOrId:, parent:flash.display:DisplayObject=null, propertyName:String=null)
:
StringGet the registration id for a display object or property.
getRuntimeMode()
:
RuntimeModeIndicates the runtime mode the layout asset is running in. Use this property to determine whether certain behaviors of the ad should be enabled or not, according to the runtime mode.
getValue(displayObjectOrId:, parent:flash.display:DisplayObject=null)
:
ObjectReturns the primitive value object container for the given display object or display object ID.
hasValue(registerId:String, parent:flash.display:DisplayObject=null)
:
BooleanChecks whether a value has been set for a display object. Use this function for optional display objects, to determine whether they should be created and registered to the parent or not.
hideFiller(registrationId:String)
:
voidHide a configurable display object or a property on a configurable display object in the filler.
import com.google.ads.studio.layouts.Layouts;
// Register the object with layouts.
var layouts:Layouts = Layouts.getInstance();
layouts.register("video", video, "Video");
// ...
layouts.hideFiller(layouts.getRegistrationId(video, null, "videoUrl");
isRegistered(displayObject:flash.display:DisplayObject)
:
BooleanReturns true if the display object has already been registered with layouts.
isStoredAsDetachedRoot(displayObject:flash.display:DisplayObject)
:
BooleanReturns true if the display object has already been detected as a detached root.
register(name:String, displayObject:flash.display:DisplayObject, fullyQualifiedType:String, parent:flash.display:DisplayObject=null, parentFullyQualifiedType:String=null)
:
StringRegister a configurable display object.
import com.google.ads.studio.layouts.Layouts;
var image:Image = new Image();
var tooltip:ToolTip = new ToolTip();
image.addChild(tooltip);
// Register image at the "root" level of the layout.
Layouts.getInstance().register("top image", image, "com.ads.Image");
// Register tooltip nested inside of image.
Layouts.getInstance().register("tooltip", tooltip, "com.ads.Tooltip",
image, "com.ads.Image");
registerDynamicScene(name:String, activateFunction:Function, parent:flash.display:DisplayObject)
:
voidRegister a dynamic scene. Use for each array item.
import com.google.ads.studio.layouts.Layouts;
[ConfigurableArrayAdd(id="Tabs", type="com.display.Tab")]
[DynamicScenes]
public function addTab(id:String):void {
// Some code that creates and registers the new tab.
var tab:Tab = new Tab();
Layouts.getInstance().register(id, tab, this);
addChild(tab);
// Register a scene for the new tab.
var selectTab:Function = function() {selectTab(tab);};
Layouts.getInstance().registerDynamicScene(id, selectTab, this);
}
registerScene(name:String, activateFunction:Function)
:
voidRegister a scene.
import com.google.ads.studio.layouts.Layouts;
var startVideo:Function = function() {
clearStage();
addChild(video);
video.play(0);
};
// Register the intro video as a scene, specifying startVideo as the
// activate scene function.
Layouts.getInstance().registerScene("Intro Video", startVideo);
reportError(error:Error=null)
:
StringReports a runtime error, caused by running the user layout code.
setActiveScene(name:String, arrayParent:flash.display:DisplayObject=null)
:
voidNotify Layouts that a scene has become active.
import com.google.ads.studio.layouts.Layouts;
// Register the start video function.
var startVideo:Function = function() {
clearStage();
addChild(video);
video.play(0);
Layouts.getInstance().sceneActive("Intro Video");
};
Layouts.getInstance().registerScene("Intro Video", startVideo);
setLayoutsValue(id:String, valueContainer:Object)
:
voidsetTestValue(id:String, valueContainer:Object)
:
voidSets a test value for local IDE testing for a configurable display object.
import com.google.ads.studio.layouts.Layouts;
layouts.setTestValue("top image", {imageTitle:"lion",
description:"roars",
url:"lion.jpg"});
setUpNewObject(id:String, displayObject:flash.display:DisplayObject, fullyQualifiedType:String, detachedRoot:flash.display:DisplayObject=null)
:
StringInitializes a newly registered display object for layouts, storing the appropriate information and building an id for it.
showFiller(registrationId:String)
:
voidShow a configurable display object or a property on a configurable display object in the filler.
import com.google.ads.studio.layouts.Layouts;
// Register the object with layouts.
var layouts:Layouts = Layouts.getInstance();
layouts.register("video", video, "Video");
// ...
layouts.showFiller(layouts.getRegistrationId(video, null, "videoUrl");
startTimer(displayObject:flash.display:DisplayObject, timerId:String)
:
voidStarts an event timer associated with a registered display object. Use this function for events that could be fired by multiple instances of the same type, in the case you need to differentiate the events fired by each instance.
var imageMouseoverHandler:Function = function(event:MouseEvent):void {
layouts.startTimer(event.target, "Hover Timer");
};
for each (var image:Sprite in images) {
image.addEventListener(MouseEvent.MOUSE_OVER, imageMouseoverHandler);
}
stopTimer(displayObject:flash.display:DisplayObject, timerId:String)
:
voidStops an event timer associated with a registered display object. Use this function for events that could be fired by multiple instances of the same type, in the case you need to differentiate the events fired by each instance.
var imageMouseoverHandler:Function = function(event:MouseEvent):void {
layouts.stopTimer(event.target, "Hover Timer");
};
for each (var image:Sprite in images) {
image.addEventListener(MouseEvent.MOUSE_OVER, imageMouseoverHandler);
}
storeDetachedRoot(parent:flash.display:DisplayObject)
:
voidStore an unregistered parent object.
updateChildrenOfDetachedRoots(parent:flash.display:DisplayObject)
:
voidResolves detached root and updates its children.