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()
:
Layouts
Returns the singleton instance of the Layouts class.
Instance Methods
Defined in: com.google.ads.studio:EnabledComponent
getEnabler()
:
Object
isInitialized()
:
Boolean
Returns whether the component has initialized.
Defined in com.google.ads.studio.layouts:Layouts
addArrayValues(id:String, arrayName:String, valueContainers:Array, classNames:Array=null)
:
int
Add an array element value object for a configurable display object.
addTestArrayValues(id:String, arrayName:String, valueContainers:Array, classNames:Array=null)
:
int
For 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)
:
void
Change 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)
:
void
Tracks 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)
:
void
Tracks 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)
:
DisplayObject
Gets the display object that was registered by the given id.
getDto(id:String)
:
DisplayObjectDto
Gets the {
getRegistrationId(displayObjectOrId:, parent:flash.display:DisplayObject=null, propertyName:String=null)
:
String
Get the registration id for a display object or property.
getRuntimeMode()
:
RuntimeMode
Indicates 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)
:
Object
Returns the primitive value object container for the given display object or display object ID.
hasValue(registerId:String, parent:flash.display:DisplayObject=null)
:
Boolean
Checks 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)
:
void
Hide 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)
:
Boolean
Returns true if the display object has already been registered with layouts.
isStoredAsDetachedRoot(displayObject:flash.display:DisplayObject)
:
Boolean
Returns 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)
:
String
Register 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)
:
void
Register 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)
:
void
Register 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)
:
String
Reports a runtime error, caused by running the user layout code.
setActiveScene(name:String, arrayParent:flash.display:DisplayObject=null)
:
void
Notify 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)
:
void
setTestValue(id:String, valueContainer:Object)
:
void
Sets 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)
:
String
Initializes a newly registered display object for layouts, storing the appropriate information and building an id for it.
showFiller(registrationId:String)
:
void
Show 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)
:
void
Starts 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)
:
void
Stops 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)
:
void
Store an unregistered parent object.
updateChildrenOfDetachedRoots(parent:flash.display:DisplayObject)
:
void
Resolves detached root and updates its children.