The VpaidTimer class is used to dispatch timer events even if there is no video object currently playing. Events are dispatched so that a custom UI can be updated, but the publisher video player is also updated with the total time left in the creative.
import com.google.ads.studio.vpaid.VpaidTimer; var timer:VpaidTimer = new VpaidTimer(15); // Fire COMPLETE after 15s.
import com.google.ads.studio.vpaid.VpaidTimer; // All the event types are accessed through VpaidTimerEvent. import com.google.ads.studio.events.VpaidTimerEvent; import com.google.ads.studio.vpaid.VpaidTimer; // Initialize the VpaidTimer; var timer:VpaidTimer = new VpaidTimer(15); // Fire COMPLETE after 15s. var tickHandler:Function = function(event:VpaidTimerEvent):void { // This will output the amount of time left before the timer completes. trace(event.countdownTime); // This will output the amount of time left in the entire creative. trace(event.adRemainingTime); }; enabler.addEventListener(VpaidTimerEvent.TICK, tickHandler);
Events
Name | Type | Description |
---|---|---|
CANCELED | com.google.ads.studio.events.VpaidTimerEvent | Dispatched if the cancel method is called on the timer. |
COMPLETE | com.google.ads.studio.events.VpaidTimerEvent | Dispatched every quarter second when the amount of time passed to the constructor has elapsed. |
TICK | com.google.ads.studio.events.VpaidTimerEvent | Dispatched every quarter second when the timer is running. |
Constructors
VpaidTimer(duration:Number=0)
Creates a new, non-reusable VpaidTimer that will report the remainging time to the enabler.
Instance Methods
Defined in com.google.ads.studio.vpaid:VpaidTimer
cancel()
:
void
Stops the timer and prevents any more events from firing. The publisher is no longer updated with the time left in the creative.