This repository has been archived by the owner on May 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
G. Managing RewardedVideo Ads
Hadi Tavakoli edited this page Jun 14, 2018
·
1 revision
To load a RewardedVideo Ad, you must have initialized the Admob ANE. The main reason for using this type of Ad is to allow your users to watch an advertising video clip for a few seconds in trade for a game coin or as called officially, rewards. RewardedVideo Ad API will dispatch a AdMobEvents.AD_DELIVER_REWARD event when the user has watched the video clip fully.
NOTE: Requesting an ad can be customized. To learn more about the possible properties, read here.
// don't forget to initialize the Admob first
// https://github.com/myflashlab/Admob-ANE/wiki/B.-Initialization-and-Listeners
AdMob.api.rewardedVideo.addEventListener(AdMobEvents.AD_DELIVER_REWARD, onDeliverReward);
var adRequest:AdRequest = new AdRequest();
AdMob.api.rewardedVideo.loadAd(adRequest, "ca-app-pub-9202401623205742/3427670519");
// now, you must wait for the banner to load before you can show it.
// of course you can show the video in other times! The only thing you
// should be careful with, is to pre-load the Ad so when you want to
//show it, it will be quickly available.
private function onAdLoaded(e:AdMobEvents):void
{
if (e.adType == AdMob.AD_TYPE_REWARDED_VIDEO)
{
// Your Ad is ready to be shown. show it whenever you like!
if(AdMob.api.rewardedVideo.isReady)
{
AdMob.api.rewardedVideo.show();
}
}
}
private function onDeliverReward(e:AdMobEvents):void
{
trace("onDeliverReward Type: " + e.rewardType + " amount: " + e.rewardAmount);
}
Enjoy building Air apps – With ♥ from MyFlashLabs Team