Display ads

In the next sections we’ll see how to display banners and video ads.

We’ll assume we have the same setup as the previous section, but we’ll also add two SuperAwesome display objects that we’ll want to show at the press of a button in our app.

import tv.superawesome.*

public class AdobeFlashDemo
       extends Sprite
       implements SALoaderInterface {

    // the loader object
    private var loader: SALoader = null;

    // ad data
    private var bannerAdData: SAAd = null;
    private var videoAdData: SAAd = null;

    // the four display objects
    private var banner: SABannerAd = null;
    private var video: SAVideoAd = null;
}

Video ads

SAVideoAd gets initialized and added in a similar way:

public class AdobeFlashDemo
       extends Sprite
       implements SALoaderInterface {

    // load ad data here ...

    public function showInLineVideo() {
        if (videoAdData != null) {
            var frame = new Rectangle(250, 450, 640, 100);
            video = new SAVideoAd(frame);
            video.setAd(videoAdData);

            // toggles a small video "click" button
            // instead of the whole video surface
            video.shouldShowSmallClickButton = true;

            addChildAt(video, 0);
            vidoe.play();
        }
    }
}

As with SABannerAd, the SAVideoAd object must be added to the view hierarchy. It also implements the same two functions: setAd(SAAd ad) and play().