When a user clicks on an ad or a related button, your application is responsible for responding. The PSDK provides you with information about the destination URL for the click.
This example shows one possible way to manage ad clicks.
<?xml version="1.0"?>
<s:VGroup xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" percentWidth="100" horizontalAlign="center" >
<fx:Declarations><fx:String id="text"></fx:String></fx:Declarations>
<s:Label text="{text}" backgroundAlpha="0.75" backgroundColor="#DEDEDE" color="#000000" paddingBottom="5" paddingRight="5" paddingLeft="5" paddingTop="5" />
</s:VGroup>
<psdk:ClickableAdsOverlay id="clickableAdsOverlay" visible="false" top="10" right="0" left="0" text="Click here for more information" click="onAdsOverlayClicked()" />
_player.addEventListener(AdPlaybackEvent.AD_STARTED, onAdStarted);_player.addEventListener(AdPlaybackEvent.AD_COMPLETED, onAdCompleted);
private function onAdStarted(event:AdPlaybackEvent):void {
var primaryAsset:AdAsset = event.ad.primaryAsset;
if (primaryAsset.adClick != null) {
clickableAdsOverlay.visible = true; }}
private function onAdCompleted(event:AdPlaybackEvent):void {
clickableAdsOverlay.visible = false;}
private function onAdsOverlayClicked():void { _mediaPlayer.view.notifyClick();}
If an ad is playing, the PSDK dispatches the AdClickEvent.AD_CLICK event, from which you can retrieve the click-through URL and related information.
_player.addEventListener(AdClickEvent.AD_CLICK, onAdClick);
private function onAdClick(event:AdClickEvent):void {
_logger.info("#onAdClick Ad clicked. Target url is {0}", event.adClick.url);
_player.pause();
var adRequest:URLRequest = new URLRequest(event.adClick.url);
navigateToURL(adRequest, event.adClick.title);}
On desktop platforms, the video ad playback area is typically used for invoking click-through URLs upon user clicks.
On mobile devices, the video ad playback area is used for other functions, such as hiding and showing controls, pausing playback, expanding to full screen, and so on. Therefore, on mobile devices, a separate view, such as a sponsor button, is usually presented to the user as a means to launch the click-through URL.