As of July 5, 2017 the Flash SDK is deprecated. We recommend using the HTML5 SDK for inline ads with web video content.

Creating an Ad Countdown Timer

For a better user experience, you may want to include an countdown timer showing the ad's remaining time. This only requires adding a few lines of code to your ActionScript.

Prerequisites

  • Flash video player with the IMA Flash SDK integrated. If you don't have one, check out our Get Started guide.
  • A VAST ad tag URL that contains a non-AdSense/AdX video ad. The UI elements for those ads are rendered by the SDK and should not be changed.

Helpful primers

  • You can read about available ad events in the AdEvent API documentation.

Create a countdown timer

Poll the remainingTime property of the AdsManager instance to get the amount of time remaining in the ad. Review the code snippet below for an example of how to add an ad countdown timer to your video player.

In an IMA Flash SDK implementation, listen to the REMAINING_TIME_CHANGED event, and check the remaining time each time it's fired.

private function adsManagerLoadedHandler(event:AdsManagerLoadedEvent):void {
  ...
  adsManager.addEventListener(AdEvent.REMAINING_TIME_CHANGED,
                              remainingTimeChangedHandler);
  ...
}

private function remainingTimeChangedHandler(event:AdEvent):void {
  var timeRemaining:Number = adsManager.remainingTime;
  // Update UI with timeRemaining
}
...

FAQ

Do some ads render their own countdown timers?
AdSense/AdX ads often render a countdown timer already. You can determine the ad system of the currently playing ad by checking Ad.adSystem.

Send feedback about...

IMA SDK for Flash
Need help? Visit our support page.