Packagecom.milkmangames.nativeextensions.ios
Classpublic class IAd
InheritanceIAd Inheritance flash.events.EventDispatcher

IAd Extension



Public Properties
 PropertyDefined By
  iAd : IAd
[static] [read-only] The current instance of the IAd singelton.
IAd
Public Methods
 MethodDefined By
  
IAd(logCallback:Function = null)
Do not call this directly; use IAd.create() to initialize or IAd.iAd to get current instance.
IAd
  
Cancels the current user interaction with the ad.
IAd
  
Cancels the current user interaction with the interstitial ad.
IAd
  
[static] Initializes the IAd Extension.
IAd
  
createBannerAd(alignment:String, usableContentSizes:int, yOffset:Number = 0):void
Starts up the iAd banner system, aligned either top or bottom, and with an optional offset value.
IAd
  
Destroys the active banner ad player.
IAd
  
dispose():void
Dispose of Context
IAd
  
isIAdAvailable():Boolean
Checks if iAd is capable of running on the current device.
IAd
  
Checks if IAd Interstitial ads are available on the running device.
IAd
  
isSupported():Boolean
[static] Checks if the current platform supports IAd.
IAd
  
setBannerVisibility(visible:Boolean, withAnimation:Boolean = false):void
Sets the requested visibility of banner ads.
IAd
  
Show an interstitial, fullscreen iPad advertisement.
IAd
Events
 Event Summary Defined By
  Dispatched when the user began interacting with a banner ad; either leaving your app to go to the app store (willLeaveApplication will be true), or is now viewing a fullscreen take over ad on to of your ad (willLeaveApplication false.) If willLeaveApplication is false, you should stop music and pause until you receive IAdEvent.BANNER_ACTION_FINISHED.IAd
  Dispatched when the user has finished interacting with a banner Ad.IAd
  Dispatched when a banner ad has failed to load.IAd
  Disapatched when a Banner Ad Has Loaded.IAd
  Dispatched when the user begins an interaction with the interstitial ad.IAd
  Dispatched when the user finishes interacting with an interstitial ad.IAd
  Dispatched when an interstitial ad has failed to load.IAd
  Dispatched when an interstitial ad has loaded.IAd
  Dispatched when an Interstitial Ad Has been unloaded from the screen.IAd
Public Constants
 ConstantDefined By
  VERSION : String = 1.0.0
[static] Current API Version
IAd
Property Detail
iAdproperty
iAd:IAd  [read-only]

The current instance of the IAd singelton. You must call IAd.create() before this property is available.


Implementation
    public static function get iAd():IAd

Throws
Error — if IAd.create() was not called before first accessing this property.
Constructor Detail
IAd()Constructor
public function IAd(logCallback:Function = null)

Do not call this directly; use IAd.create() to initialize or IAd.iAd to get current instance.

Parameters
logCallback:Function (default = null)
Method Detail
cancelBannerAction()method
public function cancelBannerAction():void

Cancels the current user interaction with the ad. If the user has clicked on a banner and is interacting with a fullscreen pop up, it will be cancelled by this call. You should avoid using this unless absolutely necessary, as it can negatively affect the value and number of ads Apple will provide your application.

cancelInterstitialAction()method 
public function cancelInterstitialAction():void

Cancels the current user interaction with the interstitial ad. If the user is viewing an interstitial ad, it will be cancelled by this call. You should avoid using this unless absolutely necessary, as it can negatively affect the value and number of ads Apple will provide your application.


Throws
Error — if interstitials are not available on this platform.
create()method 
public static function create():IAd

Initializes the IAd Extension. You should check IAd.isSupported first to ensure the platform is iOS. IAd is a Singleton and you may have only one instance. After creation, you may access the instance through the static property IAd.iAd .

Returns
IAd — initialized instance of IAd extension interface.

Throws
Error — if IAd has already been initialized.
createBannerAd()method 
public function createBannerAd(alignment:String, usableContentSizes:int, yOffset:Number = 0):void

Starts up the iAd banner system, aligned either top or bottom, and with an optional offset value. Apple serves ads, and refreshes with new ads, on an automatic timer. Apple also requires that the ad area be hidden when no ad is available to display. IAd extension manages all this behavior for you automatically. When you first call createBannerAd, iAd will start requesting ads. When an ad becomes available, it will be displayed on the screen, and you will receive the IAdEvent.BANNER_AD_LOADED when one is about to be displayed, or IAdErrorEvent.BANNER_AD_FAILED when the loading has failed. You may receive these events multiple times over the lifecycle of your application, because iAd automatically continues to try loading new ads. In the event of a failed ad load (IAdErrorEvent.BANNER_AD_FAILED) the extension will automatically hide the ad banner area, and show it again on the next successful ad load from Apple- which will also happen automatically. You do not need to do anything special other than set up listeners for these events. You should NOT destroy the ad in these events, unless you wish to discontinue its use for a prolonged period or permanently. You also do NOT need to reset the visibility in these events, unless you wish to temporarily hide the ad area during a menu transition or other change in your application. When the user clicks on an ad, you will receive the IAdEvent.BANNER_ACTION_BEGIN event. At this time, the user will either be taken out of your application to view the app store (and the event's willLeaveApplication property will be true), or they will be presented with a fullscreen advertisement to interact with, and willLeaveApplication will be false. In the latter case, you should stop the sound in your application until the IAdEvent.BANNER_ACTION_FINISHED event is fired.

Parameters

alignment:String — either IAdBannerAlignment.TOP or IAdBannerAlignment.BOTTOM - whether you want ads to show top or bottom of the screen.
 
usableContentSizes:int (default = NaN) — IAdContentSize.PORTRAIT, IAdContentSize.LANDSCAPE, or IAdContentSize.PORTRAIT_AND_LANDSCAPE. This tells iAd the possible orientations you'd like ads to display in, and it will load only ads from the server that are available in these orientations. Note that this applies to the pop up ads themselves, and not the physical banner. The banner will always be fit properly on to your phone or tablet's screen.
 
yOffset:Number (default = 0) — optional offset of the banner relative to its alignment property. You can use this if you need the shift the ad slightly up or down.

See also

destroyBannerAd()method 
public function destroyBannerAd():void

Destroys the active banner ad player. You should NOT call this in response to an IAdErrorEvent, unless you want ads to stop displaying permanently. (The extension automatically tries again later for the next working ad and displays it in these cases.) You may call destroyBannerAd() if you do not need to show ads again ever in this application, or for a long time - in those cases, it is preferable to setVisibility(false), because it will prevent your ad inventory from being spent where the user won't be able to see it.

dispose()method 
public function dispose():void

Dispose of Context

isIAdAvailable()method 
public function isIAdAvailable():Boolean

Checks if iAd is capable of running on the current device. Requires iOS 4.2+. Call this after IAd.create() and before making any other calls.

Returns
Boolean — true if the running device is capable of displaying iAds.
isInterstitialAvailable()method 
public function isInterstitialAvailable():Boolean

Checks if IAd Interstitial ads are available on the running device. Interstitials require at least iOS 4.3/iPad; your app will run banner ads on iPhone/iPod Touch, but will not be able to use Interstitial ads (banners will still work.) Use of interstitial ads also requires that you compile with AIR 3.2 or higher, or AIR 3.1 on a Macintosh, using the terminal switch -platformsdk. See the PDF documentation for more information.

Returns
Boolean — true if the current device supports iAd Interstitials (iPad)
isSupported()method 
public static function isSupported():Boolean

Checks if the current platform supports IAd. Note that this only determines whether the app is running under iOS (as opposed to Android, Windows, etc.) Use this call before initializing IAd in order to confirm that you are on iOS. (So that you can avoid initializing IAd on an unsupported platform when building a multi-platform app.)

Returns
Boolean — true if IAd is supported; false otherwise.
setBannerVisibility()method 
public function setBannerVisibility(visible:Boolean, withAnimation:Boolean = false):void

Sets the requested visibility of banner ads. Note that you do NOT need to call this in response to IAdEvent.BANNER_AD_LOADED or IAdEvent.BANNER_AD_FAILED; the extension automatically manages ad visibility in these cases. You can use this function to temporarily hide the ad when switching to a menu or screen which does not need an ad, then show it again when the user returns later. If you wish for the ad to be removed for a long period of time, or permanently, you should use IAd.iAd.destroyBannerAd() - this will prevent ad inventory from being wasted on an invisible ad.

Parameters

visible:Boolean — whether you want the ad to be visible, or invisible
 
withAnimation:Boolean (default = false) — whether you want the ad to show or hide with a quick animated slide on or off the screen.

showInterstitial()method 
public function showInterstitial():void

Show an interstitial, fullscreen iPad advertisement. These are higher value ads that take up the whole screen until the user has dismissed them. Interstitial ads are only availble on iPads, running iOS 4.3+; your app must also be compiled with AIR 3.2+, or with AIR 3.1 on a Macintosh using the terminal with the -platformsdk switch. See the documentation PDF for more info. You should use the function IAd.iAd.isInterstitialAvailable() first, to determine if this call will work and avoid an error. This action will begin loading an interstitial advertisement. If the interstitial loads successfully, it will take over the full screen of your application until the user dismisses it, and you will receive the event IAdEvent.INTERSTITIAL_AD_LOADED. At this point you should stop the sound in your application and consider pausing any important user actions. If the interstitial fails to load, you will receive the IAdErrorEvent.INTERSTITIAL_AD_FAILED event. In this case you should continue on with your application as no interstitial ads are available at this time. When an interstitial has been closed down completely, you will receive the IAdEvent.INTERSTITIAL_AD_UNLOADED event; at this juncture, you may restore your application to its normal state and continue as normal.


Throws
Error — if interstitials are not available on this platform.

See also

Event Detail
BANNER_ACTION_BEGIN Event
Event Object Type: com.milkmangames.nativeextensions.ios.events.IAdEvent

Dispatched when the user began interacting with a banner ad; either leaving your app to go to the app store (willLeaveApplication will be true), or is now viewing a fullscreen take over ad on to of your ad (willLeaveApplication false.) If willLeaveApplication is false, you should stop music and pause until you receive IAdEvent.BANNER_ACTION_FINISHED.

BANNER_ACTION_FINISHED Event  
Event Object Type: com.milkmangames.nativeextensions.ios.events.IAdEvent

Dispatched when the user has finished interacting with a banner Ad. If you had previously stopped sound or paused in response to BANNER_ACTION_BEGIN, you may resume when you receive this event.

BANNER_AD_FAILED Event  
Event Object Type: com.milkmangames.nativeextensions.ios.events.IAdErrorEvent

Dispatched when a banner ad has failed to load. The extension will handle visibility and retrying automatically, so you do not need to call any special actions in most cases for this event.

BANNER_AD_LOADED Event  
Event Object Type: com.milkmangames.nativeextensions.ios.events.IAdEvent

Disapatched when a Banner Ad Has Loaded. The ad is automatically displayed.

INTERSTITIAL_ACTION_BEGIN Event  
Event Object Type: com.milkmangames.nativeextensions.ios.events.IAdEvent

Dispatched when the user begins an interaction with the interstitial ad.

INTERSTITIAL_ACTION_FINISHED Event  
Event Object Type: com.milkmangames.nativeextensions.ios.events.IAdEvent

Dispatched when the user finishes interacting with an interstitial ad.

INTERSTITIAL_AD_FAILED Event  
Event Object Type: com.milkmangames.nativeextensions.ios.events.IAdErrorEvent

Dispatched when an interstitial ad has failed to load.

INTERSTITIAL_AD_LOADED Event  
Event Object Type: com.milkmangames.nativeextensions.ios.events.IAdEvent

Dispatched when an interstitial ad has loaded. The interstitial will now be displayed a fullscreen takeover, and you should stop any sound and pause important actions until you receive IAdEvent.INTERSTITIAL_AD_UNLOADED.

INTERSTITIAL_AD_UNLOADED Event  
Event Object Type: com.milkmangames.nativeextensions.ios.events.IAdEvent

Dispatched when an Interstitial Ad Has been unloaded from the screen. If you had previously stopped sound or paused in response to IAdEvent.INTERSTITIAL_AD_LOADED, you may resume in response to this event.

Constant Detail
VERSIONConstant
public static const VERSION:String = 1.0.0

Current API Version