The DynamicContent class retrieves dynamic content from a flashvar so that it is available to the designer. The original form of the content is in an escaped JSON string. It also is able to ingest development values to be used in preview.
var info:String = DynamicContent.getInstance().camera[0].info;
import com.google.ads.studio.dynamiccontent.DynamicContent; // All the event types are accessed through StudioEvent. import com.google.ads.studio.events.StudioEvent; // Get a reference to the DynamicContent. var dynamicContent:DynamicContent = DynamicContent.getInstance(); var contentAvailableHandler:Function = function(event:StudioEvent):void { // This will output the value of StudioEvent.LOAD // which is "load". trace(event.type); // Access some information. var info:String = dynamicContent.camera[0].info; }; dynamicContent.addEventListener( StudioEvent.LOAD, contentAvailableHandler); // DynamicContent is a dynamic class so you can set development values for // for testing in a non-live environment. Development values are // provided to you by the Dynamic Content web application. dynamicContent.camera[0].info = "This is a great camera!"; // Initialize the DynamicContent! This will retrieve the runtime dynamic // content when run in a live environment. dynamicContent.init();
Events
Name | Type | Description |
---|---|---|
FAIL | com.google.ads.studio.events.StudioEvent | Dispatched when retrieval of dynamic content fails for any reason. |
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 the dynamic content is available. |
Static Methods
DynamicContent.getInstance()
:
DynamicContent
Returns the singleton instance of the DynamicContent 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.dynamiccontent:DynamicContent
getProfileId()
:
Number
Returns the profile ID.
init()
:
void
Initializes the component.
isFeedLoggingEnabled()
:
Boolean
Returns whether logging is enabled.
setDebugValues(debugValues:Object)
:
void
A convenience method to set the debug values from a given object.
setFeedLoggingEnabled(value:Boolean=true)
:
void
Enables/Disables output of ad's feed into console. Default value is
true
.
setProfileId(profileId:Number)
:
void
Sets the profile ID.