The Expanding component helps you design an expanding creative. It provides an API to expand and collapse the creative. Additionally, you can set it to run actions (control playhead and invoke functions) when an expand or collapse occurs. It may also load panels, each of which loads in an external SWF and can run its own actions. The component provides standard expanding metrics to DoubleClick Studio.
For more information, see Expanding creatives overview.
import com.google.ads.studio.events.StudioEvent; import com.google.ads.studio.utils.StudioClassAccessor; var expandHandler:Function = function(event:StudioEvent):void { trace(event.panel + " Expanded!"); }; var collapseHandler:Function = function(event:StudioEvent):void { trace("Collapsed!"); }; var expanding:Object = StudioClassAccessor. getClass(StudioClassAccessor.CLASS_EXPANDING)["getInstance"](); expanding.addEventListener(StudioEvent.EXPAND, expandHandler); expanding.addEventListener(StudioEvent.COLLAPSE_COMPLETE, collapseHandler); expanding.expand(); expanding.collapse();
Events
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
COLLAPSE_BEGIN | com.google.ads.studio.events.StudioEvent | Dispatched when a collapse is begun. import com.google.ads.studio.events.StudioEvent; var collapseBeginHandler:Function = function(event:StudioEvent):void { trace("Collapse begins."); }; expanding.addEventListener( StudioEvent.COLLAPSE_BEGIN, collapseBeginHandler); | ||||||
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."); }; expanding.addEventListener( StudioEvent.COLLAPSE_COMPLETE, collapseCompleteHandler); | ||||||
EXPAND | com.google.ads.studio.events.StudioEvent | Dispatched when an expansion is completed. The properties of the event object have the following values:
import com.google.ads.studio.events.StudioEvent; var expandHandler:Function = function(event:StudioEvent):void { trace(event.panel + " has expanded."); }; expanding.addEventListener(StudioEvent.EXPAND, expandHandler); | ||||||
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); } | ||||||
LOAD | com.google.ads.studio.events.StudioEvent | Dispatched when an expanding panel movieClip has loaded. The properties of the event object have the following values:
import com.google.ads.studio.events.StudioEvent; var loadHandler:Function = function(event:StudioEvent):void { var child:Object = event.movieClipContent; trace(event.panelName + " loaded."); }; expanding.addEventListener(StudioEvent.LOAD, loadHandler); | ||||||
LOAD_INIT | com.google.ads.studio.events.StudioEvent | Dispatched when an expanding panel MovieClip has started loading. The properties of the event object have the following values:
import com.google.ads.studio.events.StudioEvent; var loadHandler:Function = function(event:StudioEvent):void { var child:Object = event.movieClipContent; trace(event.panelName + " loaded."); }; expanding.addEventListener(StudioEvent.LOAD_INIT, loadHandler); |
Constructors
Expanding()
:
void
Creates an Expanding component.
Static Methods
Expanding.getInstance()
:
Expanding
Returns the instance of the Expanding component.
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.expanding:Expanding
collapse()
:
void
Collapses the creative and the currently open panel, if one exists.
var collapseClickHandler:Function = function(event:MouseEvent):void { expanding.collapse(); }; collapseButton.addEventListener(MouseEvent.CLICK, collapseClickHandler);
endAnimatedCollapse()
:
void
Invoke this function at the end of a collapse animation to denote that the creative is ready to be masked.
expanding.endAnimatedCollapse();
expand(panelName:String=null)
:
void
Expands the creative with an optional child panel name to expand. Collapses any other child panels that may be expanded. We disable the button in order to allow any buttons sitting below to be clickable.
var expandClickHandler:Function = function(event:MouseEvent):void { expanding.expand(); }; expandButton.addEventListener(MouseEvent.CLICK, expandClickHandler);
getExpandedDirection()
:
String
Returns the direction to expand.
var expandingInitHandler:Function = function(event:StudioEvent):void { trace("Expanding direction is " + expanding.getExpandedDirection() + "."); // Results will be one of tr, tl, br, bl }; expanding.addEventListener(StudioEvent.INIT, expandingInitHandler);
setBottomChild(panelName:String)
:
void
Sets the panel to expand in bottom direction.
var expandingInitHandler:Function = function(event:StudioEvent):void { expanding.setBottomChild("Child Bottom"); }; expanding.addEventListener(StudioEvent.INIT, expandingInitHandler);
setBottomLeftChild(panelName:String)
:
void
Sets the panel to expand in bottom-left direction.
var expandingInitHandler:Function = function(event:StudioEvent):void { expanding.setBottomLeftChild("Child Bottom Left"); }; expanding.addEventListener(StudioEvent.INIT, expandingInitHandler);
setBottomRightChild(panelName:String)
:
void
Sets the panel to expand in bottom-right direction.
var expandingInitHandler:Function = function(event:StudioEvent):void { expanding.setBottomRightChild("Child Bottom Right"); }; expanding.addEventListener(StudioEvent.INIT, expandingInitHandler);
setCollapseOnMouseOut(collapseOnMouseOut:Boolean)
:
void
Sets whether or not to collapse when the user rolls out of the stage.
var expandingInitHandler:Function = function(event:StudioEvent):void { expanding.setCollapseOnMouseOut(true); }; expanding.addEventListener(StudioEvent.INIT, expandingInitHandler);
setExpandOnClick(expandOnClick:Boolean)
:
void
Sets whether or not to expand on click.
var expandingInitHandler:Function = function(event:StudioEvent):void { expanding.setExpandOnClick(true); }; expanding.addEventListener(StudioEvent.INIT, expandingInitHandler);
setExpandOnMouseOver(expandOnMouseOver:Boolean)
:
void
Sets whether or not to expand on mouse-over.
var expandingInitHandler:Function = function(event:StudioEvent):void { expanding.setExpandOnMouseOver(true); }; expanding.addEventListener(StudioEvent.INIT, expandingInitHandler);
setLeftChild(panelName:String)
:
void
Sets the panel to expand in left direction.
var expandingInitHandler:Function = function(event:StudioEvent):void { expanding.setLeftChild("Child Left"); }; expanding.addEventListener(StudioEvent.INIT, expandingInitHandler);
setReportLinearChange(reportLinearChange:Boolean)
:
void
setRightChild(panelName:String)
:
void
Sets the panel to expand in right direction.
var expandingInitHandler:Function = function(event:StudioEvent):void { expanding.setRightChild("Child Right"); }; expanding.addEventListener(StudioEvent.INIT, expandingInitHandler);
setTopChild(panelName:String)
:
void
Sets the panel to expand in top direction.
var expandingInitHandler:Function = function(event:StudioEvent):void { expanding.setTopChild("Child Top"); }; expanding.addEventListener(StudioEvent.INIT, expandingInitHandler);
setTopLeftChild(panelName:String)
:
void
Sets the panel to expand in top-left direction.
var expandingInitHandler:Function = function(event:StudioEvent):void { expanding.setTopLeftChild("Child Top Left"); }; expanding.addEventListener(StudioEvent.INIT, expandingInitHandler);
setTopRightChild(panelName:String)
:
void
Sets the panel to expand in top-right direction.
var expandingInitHandler:Function = function(event:StudioEvent):void { expanding.setTopRightChild("Child Top Right"); }; expanding.addEventListener(StudioEvent.INIT, expandingInitHandler);
startExpanded(panelName:String=null)
:
void
Starts the creative in an expanded state without tracking an expand event.
var expandingInitHandler:Function = function(event:StudioEvent):void { expanding.startExpanded("Expanded Panel Name"); }; expanding.addEventListener(StudioEvent.INIT, expandingInitHandler);