Configurable allows designers to define a layout which can be customized by Studio users.
import com.google.ads.studio.configurable.Configurable; var image:Image = new Image(); var tooltip:ToolTip = new ToolTip(); image.addChild(tooltip); // Register image at the "root" level of the layout. Configurable.getInstance().register("top image", image); // Register tooltip nested inside of image. Configurable.getInstance().register("tooltip", tooltip, image);
Constants
Name | Value | Description |
---|---|---|
FILLER_CONTEXT_CREATIVE | CREATIVE | Creative filler context. |
FILLER_CONTEXT_MANAGEMENT | MANAGEMENT | Management filler context. |
FILLER_CONTEXT_NONE | NONE | Not in filler context. |
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); } | ||||||||
STATE_ACTIVE | com.google.ads.studio.events.StudioEvent | Dispatched just before the Configurable component activates a state. The properties of the event object have the following values:
import com.google.ads.studio.events.StudioEvent; var stateChangeHandler:Function = function(event:StudioEvent):void { if (event.isDynamic) { // Make sure the state's parent object is on display. var stateParentObject:DisplayObject = event.parent; clearStage(); addChild(stateParentObject); trace("A dynamic state is now active:" + event.stateName); } else { trace("A state is now active:" + event.stateName); } }; Configurable.getInstance().addEventListener( StudioEvent.STATE_ACTIVE, stateChangeHandler); | ||||||||
UPDATE | com.google.ads.studio.events.StudioEvent | Dispatched by the registered object when it has been updated. import com.google.ads.studio.events.StudioEvent; var imageUpdateHandler:Function = function(event:StudioEvent):void { trace("Image was updated."); }; var image:Image = new Image(); Configurable.getInstance().register("top image", image); image.addEventListener( StudioEvent.UPDATE, imageUpdateHandler); |
Static Methods
Configurable.getInstance()
:
Configurable
Returns the singleton instance of the Configurable 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.configurable:Configurable
changeFillerValue(registrationId:String, value:Object)
:
void
Change the value of a configurable object in the filler. Sets the value on the registered object if found, but does not call any ConfigurableUpdate.
import com.google.ads.studio.configurable.Configurable; // Register the object with configurable. var config:Configurable = Configurable.getInstance(); config.register("video", video); // ... config.changeFillerValue(config.getRegistrationId(video), {videoUrl: "www.google.com"});
counter(registeredObject:Object, eventId:String, isCumulative:Boolean=false)
:
void
Tracks a counter event for a registered 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 { configurablecounter(event.target, "Expand Counter"); images[i].expand(); }; for each (var button:Sprite in expandButtons) { button.addEventListener(MouseEvent.CLICK, expandClickHandler); }
exit(registeredObject:Object, exitId:String)
:
void
Tracks an exit event for a registered object in the layout.
var linkClickHandler:Function = function(event:MouseEvent):void { configurable.exit(event.target, "Click Exit"); }; for each (var link:Sprite in links) { link.addEventListener(MouseEvent.CLICK, linkClickHandler); }
getDynamicProfileId()
:
Number
Returns the dynamic profile ID.
getFillerContext()
:
String
Indicates the filler context that the layout asset is running in.
getRegisteredObject(name:String)
:
Object
Returns the registered object based on its registration ID.
getRegisteredParent(object:Object)
:
Object
Returns the registered object's parent configurable object.
getRegistrationId(objectOrId:, parentObjectOrId:String=null, propertyName:=null)
:
String
Get the registration id for an 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(objectOrPropertyName:, parent:Object=null)
:
Object
Returns the value object container for the given object or its property name with its parent reference.
hasValue(registerId:String, parent:Object=null)
:
Boolean
Checks whether a value has been set for an object. Use this function for optional objects, to determine whether they should be created and registered to the parent or not.
hideFiller(registrationId:String)
:
void
Hide a configurable object or a property on a configurable object in the filler.
import com.google.ads.studio.configurable.Configurable; // Register the object with configurable. var config:Configurable = Configurable.getInstance(); config.register("video", video); // ... config.hideFiller(config.getRegistrationId(video, null, "videoUrl");
isRegistered(object:Object)
:
Boolean
Returns whether or not an object is currently registered.
refreshAll(object:Object=null)
:
void
Refreshes registered objects and their children.
register(name:String, object:Object, parent:Object=null)
:
void
Register a configurable object.
import com.google.ads.studio.configurable.Configurable; var image:Image = new Image(); var tooltip:ToolTip = new ToolTip(); image.addChild(tooltip); // Register image at the "root" level of the layout. Configurable.getInstance().register("top image", image); // Register tooltip nested inside of image. Configurable.getInstance().register("tooltip", tooltip, image);
registerDynamicState(name:String, activateFunction:Function, parent:Object)
:
void
Register a dynamic state. Use for each array item.
import com.google.ads.studio.configurable.Configurable; [ConfigurableArrayAdd(id="Tabs", type="com.display.Tab")] [DynamicStates] public function addTab(id:String):void { // Some code that creates and registers the new tab. var tab:Tab = new Tab(); Configurable.getInstance().register(id, tab, this); addChild(tab); // Register a state for the new tab. var selectTab:Function = function() {selectTab(tab);}; Configurable.getInstance().registerDynamicState(id, selectTab, this); }
registerState(name:String, activateFunction:Function)
:
void
Register a state.
import com.google.ads.studio.configurable.Configurable; var startVideo:Function = function() { clearStage(); addChild(video); video.play(0); }; // Register the intro video as a state, specifying startVideo as the // activate state function. Configurable.getInstance().registerState("Intro Video", startVideo);
setActiveState(name:String, parent:Object=null)
:
void
Notify Configurable that a state has become active.
import com.google.ads.studio.configurable.Configurable; // Register the start video function. var startVideo:Function = function() { clearStage(); addChild(video); video.play(0); Configurable.getInstance().stateActive("Intro Video"); }; Configurable.getInstance().registerState("Intro Video", startVideo);
setDynamicProfileId(dynamicProfileId:Number)
:
void
Sets the dynamic profile ID.
setTestValue(value:Object, path:String=null)
:
void
Updates the test value tree for configurable. The new value passed to this method will be merged into existing value tree. For example
Configurable.getInstance().setTestValue({ background: { url: "", title: "background image" } });will setup a background object at the root level, then you can use
Configurable.getInstance().setTestValue({ url: "http://" }, "background");to change the value of "background.url" from "" to "http://".
showFiller(registrationId:String)
:
void
Show a configurable object or a property on a configurable object in the filler.
import com.google.ads.studio.configurable.Configurable; // Register the object with configurable. var config:Configurable = Configurable.getInstance(); config.register("video", video); // ... config.showFiller(config.getRegistrationId(video, null, "videoUrl");
showMessage(message:String)
:
void
Shows a message in the filler UI. Can be used to inform the user of any filler changes.
import com.google.ads.studio.configurable.Configurable; var config:Configurable = Configurable.getInstance(); config.showMessage("hello world");
startTimer(registeredObject:Object, timerId:String)
:
void
Starts an event timer associated with a registered 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 { configurable.startTimer(event.target, "Hover Timer"); }; for each (var image:Sprite in images) { image.addEventListener(MouseEvent.MOUSE_OVER, imageMouseoverHandler); }
stopTimer(registeredObject:Object, timerId:String)
:
void
Stops an event timer associated with a registered 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 { configurablestopTimer(event.target, "Hover Timer"); }; for each (var image:Sprite in images) { image.addEventListener(MouseEvent.MOUSE_OVER, imageMouseoverHandler); }
unregister(object:Object)
:
Boolean
Unregisters an object from the value tree. It will remove the binding from the associated data model, so any changes won't trigger the view object to update. The data model will continue to receive updates so when the object is registered again, it will receive the most up-to-date data.