{"id":3009,"date":"2014-03-18T17:51:51","date_gmt":"2014-03-19T00:51:51","guid":{"rendered":"http:\/\/www.nathalielawhead.com\/candybox\/?p=3009"},"modified":"2014-03-18T17:53:59","modified_gmt":"2014-03-19T00:53:59","slug":"introduction-to-iad-in-flash-air-for-ios-kick-start-tutorial-samples","status":"publish","type":"post","link":"http:\/\/www.nathalielawhead.com\/candybox\/introduction-to-iad-in-flash-air-for-ios-kick-start-tutorial-samples","title":{"rendered":"Introduction to iAd in Flash AIR for iOS &#8211; Kick Start Tutorial &#038; Samples"},"content":{"rendered":"<p>Sourcefiles for the tutorials <a href=\"http:\/\/nathalielawhead.com\/sourcefiles\/StageAd_iAd_WorkingExample\/\" target=\"_blank\">are here<\/a>.<\/p>\n<p><strong>SUMMARY<\/strong><\/p>\n<p>It can be very confusing to know where to start when you want to add advertisements in your Flash\/AIR based iOS app. Google search results can be ambiguous at best, and there are a number of free solutions out there, but little or no support. The most recommended pay for solution is <a href=\"http:\/\/www.milkmangames.com\/blog\/tools\/\" target=\"_blank\">Milkman Games\u2019s iAd for iOS<\/a> Extension. There are also a number of others (like <a href=\"http:\/\/lancelotmobile.com\/blog\/smaato-ane\/\" target=\"_blank\">Smaato For Android and iOS <\/a>) for pay, but I\u2019m a firm believer in that \u201cif they do it, I should be able to do it too\u201d.<br \/>\n&#8230;I&#8217;d like to make my own ANE someday. That would be so awesome.<\/p>\n<p>Once you find a service you will quickly figure out that relying on one ad network (like iAd) isn\u2019t enough. iAd only shows ads in specific countries, for example.<br \/>\nIf you plan to use the \u201cpay to remove ads\u201d feature, you will need to use more than one ad network. If you don\u2019t, some people will essentially get the game\/app for free.<br \/>\nTo avoid this you would need to use a number of other services. If one fails then fall back on the other \u2014 like <a href=\"http:\/\/developers.tapjoy.com\/resources\/\" target=\"_blank\">Tapjoy<\/a>, <a href=\"http:\/\/www.placeplay.com\/\" target=\"_blank\">Placeplay<\/a>, <a href=\"https:\/\/developers.google.com\/mobile-ads-sdk\/?hl=en\" target=\"_blank\">Admob<\/a>, <a href=\"http:\/\/sdk.revmobmobileadnetwork.com\/air\" target=\"_blank\">RevMob<\/a>. Most of them provide their own AIR SDKs. Then you would have to write your own ad mediation (if iAd fails, show from other service, if that fails, show the other, if that fails have a final fallback showing something that promotes your work &#8212; a &#8220;house ad&#8221;\u2026), etc. Some SDK\u2019s will do this for you (like <a href=\"http:\/\/code.google.com\/p\/adwhirl\/\" target=\"_blank\">adwhirl<\/a>) \u2014 specify\/linkup your network (links bellow, see <strong>More iAd ane\u2019s (SDKs, etc)<\/strong>).<br \/>\nFrom what I have heard (but can\u2019t stand by because I haven\u2019t tried it) displaying ads are not the best way to generate revenue (don\u2019t base a business model on it because of those overnight success stories!). It takes a lot more effort than that.<\/p>\n<p>My goal for this post is to save people time, hassle, and hopefully money, by offering sourcecode samples, and a compilation of links all in one convenient place. I will continue to build on, and update, this post as I find more.<\/p>\n<p><strong>RESOURCES<\/strong><\/p>\n<p><strong>Documentation:<\/strong><br \/>\nAdobe\u2019s docs for All Packages: <a href=\"http:\/\/www.adobe.com\/devnet-docs\/gamingsdk\/anedocs\/\" target=\"_blank\">http:\/\/www.adobe.com\/devnet-docs\/gamingsdk\/anedocs\/<\/a><\/p>\n<p>StageAd docs: <a href=\"http:\/\/www.adobe.com\/devnet-docs\/gamingsdk\/anedocs\/com\/adobe\/ane\/stageAd\/package-detail.html\" target=\"_blank\">http:\/\/www.adobe.com\/devnet-docs\/gamingsdk\/anedocs\/com\/adobe\/ane\/stageAd\/package-detail.html<\/a><\/p>\n<p>Adobe Gaming SDK support forum: <a href=\"http:\/\/forums.adobe.com\/community\/game_developers\/adobe_gaming_sdk\" target=\"_blank\">http:\/\/forums.adobe.com\/community\/game_developers\/adobe_gaming_sdk<\/a> &#8211;If you have an issue, this is where you would search for answers (not always on Google).<\/p>\n<p><a href=\"http:\/\/www.adobe.com\/devnet\/games\/getting-started-games.html\" target=\"_blank\">Getting started with Adobe Game Developer Tools<\/a><\/p>\n<p>It is also a good idea to browse through Apple\u2019s iAd Programming Guide: <a href=\"https:\/\/developer.apple.com\/library\/ios\/documentation\/userexperience\/conceptual\/iAd_Guide\/Introduction\/Introduction.html#\/\/apple_ref\/doc\/uid\/TP40009881-CH1-SW1\" target=\"_blank\">HERE<\/a>.<br \/>\nFrom what I heard (and know from their process) they have some fairly strict requirements for how you are allowed to display Ads. For example their fullscreen ads section: <a href=\"https:\/\/developer.apple.com\/library\/ios\/documentation\/userexperience\/conceptual\/iAd_Guide\/Full-ScreenAdvertisements\/Full-ScreenAdvertisements.html\" target=\"_blank\">HERE<\/a>.<br \/>\nThis will make your app less likely to be rejected for &#8220;overlooked&#8221; reasons\u2026<\/p>\n<p><strong>More Air Native Extensions:<\/strong><br \/>\n<a href=\"http:\/\/www.as3gamegears.com\/category\/air-native-extension\/\" target=\"_blank\">http:\/\/www.as3gamegears.com\/category\/air-native-extension\/<\/a> This is one of the best places that rounds up resources for AS3. In this case it\u2019s a great collection for any App developer. Like <a href=\"http:\/\/www.as3gamegears.com\/air-native-extension\/ane-cameraroll\/\" target=\"_blank\">CameraRoll<\/a>, <a href=\"http:\/\/www.as3gamegears.com\/air-native-extension\/iad-ane\/\" target=\"_blank\">iAd<\/a>, <a href=\"http:\/\/www.as3gamegears.com\/air-native-extension\/ad-network\/\" target=\"_blank\">Ad Network<\/a>, etc\u2026 It\u2019s a very exciting summary to get you started, and will save you time.<\/p>\n<p>Adobe AIR Native Extensions round-up: <a href=\"http:\/\/flashdaily.net\/post\/77053654343\/adobe-air-native-extensions-round-up\" target=\"_blank\">HERE<\/a>, has some more good links to other iAd solutions.<\/p>\n<p><strong>More iAd ane\u2019s (SDKs, etc):<\/strong><br \/>\n<a href=\"http:\/\/code.google.com\/p\/adwhirl-flash-sdk\/\" target=\"_blank\">adwhirl-flash-sdk<\/a> (An unofficial port of the Adwhirl Client SDK to Actionscript 3. <a href=\"https:\/\/groups.google.com\/forum\/?fromgroups=#!topic\/adwhirl-users\/pMNPZV8yPRg[1-25-false]\" target=\"_blank\">Usage HERE (see first post)<\/a>. Source here: <a href=\"http:\/\/code.google.com\/p\/adwhirl-flash-sdk\/source\/browse\/#svn%2Ftrunk%2Fcom%2Fadwhirl\" target=\"_blank\">HERE<\/a>.)<\/p>\n<p><a href=\"http:\/\/code.google.com\/p\/iad-ane-for-flash-air-mobile-ios\/\" target=\"_blank\">iad-ane-for-flash-air-mobile-ios<\/a> (A free actionscript native extension for iAd, for Flash AIR for iOS applications. Android is not supported. This air ane supports all native function, including all size type banners, interstitial, and events\u2026)<\/p>\n<p><a href=\"http:\/\/code.google.com\/p\/adoble-flash-air-ad-network-framework\/\" target=\"_blank\">adoble-flash-air-ad-network-framework<\/a> (adwhirl for actionscript. Like adwhirl, but simpler, and no need for a server. Add a variety of ad networks advertising in mobile applications. Comes with support for admob (ios, android), inmobi (ios, android), chartboost (ios, android), iad (ios) 4 ad platforms\u2026<\/p>\n<p><a href=\"http:\/\/code.google.com\/p\/adwhirl\/\" target=\"_blank\">adwhirl<\/a> (Use the AdWhirl technology to display ads from different ad networks in your Android and iPhone applications. Switch ad networks on the fly, all for free. With the source code available, you can see how it all works. ) <\/p>\n<p><a href=\"http:\/\/lancelotmobile.com\/blog\/smaato-ane\/\" target=\"_blank\">Smaato ANE<\/a> (Not free. The iOS version can be configured to show Apple iAd. If iAd fails and can\u2019t be fetched then a iSmaato banner is displayed.)<\/p>\n<p><strong>Keep These Tutorials At Hand:<\/strong><br \/>\nUsing the Game Center Adobe AIR native extensions for iOS: <a href=\"http:\/\/www.adobe.com\/devnet\/air\/articles\/gamecenter-ane-ios.html\" target=\"_blank\">http:\/\/www.adobe.com\/devnet\/air\/articles\/gamecenter-ane-ios.html<\/a><\/p>\n<p><strong>Getting StageAd:<\/strong><\/p>\n<p>You may download all the SDK\u2019s, ane\u2019s, libraries, etc. from Adobe Gaming\u2019s (very impressive &#038; helpful) Adobe Gaming SDK: <a href=\"http:\/\/gaming.adobe.com\/technologies\/gamingsdk\/\" target=\"_blank\">http:\/\/gaming.adobe.com\/technologies\/gamingsdk\/<\/a><\/p>\n<p>Once you do this you need StageAd.ane<br \/>\nIt should be provided in the \u201c<em>Native Extensions (ANEs)<\/em>\u201d folder of Adobe Gaming SDK.<br \/>\nDocs are also provided in the \u201cDocs\u201d folder. In this case <em>Native Extensions (ANEs)>Docs>com>adobe>ane>stageAd<\/em>\u2026<\/p>\n<p>Working examples are in <em>Samples>Native Extensions (ANEs)>StageAd>src<\/em><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nathalielawhead.com\/sourcefiles\/StageAd_iAd_WorkingExample\/stageAd_folder.png\" alt=\"\" \/><\/p>\n<p><strong>TUTORIAL<\/strong><\/p>\n<p><em><strong>stageAd EXAMPLE<\/strong><\/em><br \/>\n<strong>Getting StageAd Running In Flash CS6, Flash CC<\/strong><\/p>\n<p>Start a new AIR for iOS project.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nathalielawhead.com\/sourcefiles\/StageAd_iAd_WorkingExample\/stageAd_01.png\" alt=\"\" \/><\/p>\n<p>Open the <em>Edit ActionScript<\/em> settings window. Click on the Wrench icon next to the ActionScript tab in the Properties panel.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nathalielawhead.com\/sourcefiles\/StageAd_iAd_WorkingExample\/stageAd_02.png\" alt=\"\" \/><\/p>\n<p>Go to the Library path tab.<\/p>\n<p>Select <em>Add New Path<\/em>.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nathalielawhead.com\/sourcefiles\/StageAd_iAd_WorkingExample\/stageAd_03.png\" alt=\"\" \/><\/p>\n<p>Then <em>Browse to a Native Extension (ANE)<\/em> file.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nathalielawhead.com\/sourcefiles\/StageAd_iAd_WorkingExample\/stageAd_04.png\" alt=\"\" \/><\/p>\n<p>Navigate to the <em>StageAd.ane<\/em><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nathalielawhead.com\/sourcefiles\/StageAd_iAd_WorkingExample\/stageAd_05.png\" alt=\"\" \/><\/p>\n<p>And hit OK.<br \/>\nThat\u2019s the setup\u2026<\/p>\n<p><strong>Code:<\/strong><\/p>\n<p>Again, stageAd <a href=\"http:\/\/www.adobe.com\/devnet-docs\/gamingsdk\/anedocs\/com\/adobe\/ane\/stageAd\/package-detail.html\" target=\"_blank\">docs are here<\/a>.<br \/>\nThe samples given by Adobe in <em>Samples>Native Extensions (ANEs)>StageAd>src<\/em> are more elaborate. This is a very simplified example\/walkthrough.<\/p>\n<p>Following is for a simple banner positioned bottom or top of the screen.<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%\"><span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">com.adobe.ane.stageAd.<\/span><span style=\"color: #333333\">*;<\/span>\r\n\r\n<span style=\"color: #888888\">\/\/create an instance of a normal banner ad<\/span>\r\n<span style=\"color: #008800; font-weight: bold\">var<\/span> ad:<span style=\"color: #333399; font-weight: bold\">StageBannerAd<\/span><span style=\"color: #333333\">;<\/span>\r\n\r\n<span style=\"color: #888888\">\/\/HANDLERS<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold\">function <\/span><span style=\"color: #0066BB; font-weight: bold\">onActionCompleteHandler<\/span><span style=\"color: #333333\">(<\/span>event<span style=\"color: #333333\">:<\/span><span style=\"color: #333399; font-weight: bold\">StageAdEvent<\/span><span style=\"color: #333333\">)<\/span>\r\n<span style=\"color: #333333\">{<\/span>\r\n\r\n\t<span style=\"color: #0066BB; font-weight: bold\">trace<\/span><span style=\"color: #333333\">(<\/span><span style=\"background-color: #fff0f0\">&quot;Action complete handler properties:bubbles-&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">bubbles<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;cancelable:&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">cancelable<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;target:&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">target<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;type:&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">type<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;leaveApplication&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">willLeaveApplication<\/span><span style=\"color: #333333\">);<\/span>\r\n\r\n<span style=\"color: #333333\">}<\/span>\r\n\r\n\r\n<span style=\"color: #008800; font-weight: bold\">function <\/span><span style=\"color: #0066BB; font-weight: bold\">onAdLoadCompleteHandler<\/span><span style=\"color: #333333\">(<\/span>event<span style=\"color: #333333\">:<\/span><span style=\"color: #333399; font-weight: bold\">StageAdEvent<\/span><span style=\"color: #333333\">)<\/span>\r\n<span style=\"color: #333333\">{<\/span>\r\n\r\n\t<span style=\"color: #0066BB; font-weight: bold\">trace<\/span><span style=\"color: #333333\">(<\/span><span style=\"background-color: #fff0f0\">&quot;AD load handler properties:bubbles-&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">bubbles<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;cancelable:&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">cancelable<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;target:&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">target<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;type:&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">type<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;leaveApplication&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">willLeaveApplication<\/span><span style=\"color: #333333\">);<\/span>\r\n\r\n<span style=\"color: #333333\">}<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold\">function <\/span><span style=\"color: #0066BB; font-weight: bold\">onActionStartingHandler<\/span><span style=\"color: #333333\">(<\/span>event<span style=\"color: #333333\">:<\/span><span style=\"color: #333399; font-weight: bold\">StageAdEvent<\/span><span style=\"color: #333333\">)<\/span>\r\n<span style=\"color: #333333\">{<\/span>\r\n\t<span style=\"color: #0066BB; font-weight: bold\">trace<\/span><span style=\"color: #333333\">(<\/span><span style=\"background-color: #fff0f0\">&quot;Action starting handler properties:bubbles-&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">bubbles<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;cancelable:&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">cancelable<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;target:&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">target<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;type:&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">type<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;leaveApplication&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">willLeaveApplication<\/span><span style=\"color: #333333\">);<\/span>\r\n\r\n<span style=\"color: #333333\">}<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold\">function <\/span><span style=\"color: #0066BB; font-weight: bold\">onAdLoadFailHandler<\/span><span style=\"color: #333333\">(<\/span>event<span style=\"color: #333333\">:<\/span><span style=\"color: #333399; font-weight: bold\">StageAdEvent<\/span><span style=\"color: #333333\">)<\/span>\r\n<span style=\"color: #333333\">{<\/span>\r\n\t<span style=\"color: #0066BB; font-weight: bold\">trace<\/span><span style=\"color: #333333\">(<\/span><span style=\"background-color: #fff0f0\">&quot;ADLoadfail handler properties:bubbles-&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">bubbles<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;cancelable:&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">cancelable<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;target:&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">target<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;type:&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">type<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;leaveApplication&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">willLeaveApplication<\/span><span style=\"color: #333333\">);<\/span>\r\n\r\n<span style=\"color: #333333\">}<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold\">function <\/span><span style=\"color: #0066BB; font-weight: bold\">onAdUnloadHandler<\/span><span style=\"color: #333333\">(<\/span>event<span style=\"color: #333333\">:<\/span><span style=\"color: #333399; font-weight: bold\">StageAdEvent<\/span><span style=\"color: #333333\">)<\/span>\r\n<span style=\"color: #333333\">{<\/span>\r\n\t<span style=\"color: #0066BB; font-weight: bold\">trace<\/span><span style=\"color: #333333\">(<\/span><span style=\"background-color: #fff0f0\">&quot;AdUnload handler properties:bubbles-&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">bubbles<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;cancelable:&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">cancelable<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;target:&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">target<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;type:&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">type<\/span> <span style=\"color: #333333\">+<\/span> <span style=\"background-color: #fff0f0\">&quot;leaveApplication&quot;<\/span> <span style=\"color: #333333\">+<\/span> event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">willLeaveApplication<\/span><span style=\"color: #333333\">);<\/span>\r\n<span style=\"color: #333333\">}<\/span>\r\n\r\n<span style=\"color: #888888\">\/\/Normal advertisements<\/span>\r\n<span style=\"color: #008800; font-weight: bold\">if<\/span> <span style=\"color: #333333\">(<\/span>StageBannerAd<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">isSupported<\/span><span style=\"color: #333333\">)<\/span>\r\n<span style=\"color: #333333\">{<\/span>\r\n\r\n\tad <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">new<\/span> <span style=\"color: #333399; font-weight: bold\">StageBannerAd<\/span><span style=\"color: #333333\">();<\/span>\r\n\t<span style=\"color: #888888\">\/\/if set to true the ad will only display once loaded<\/span>\r\n\tad<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">showOnlyIfLoaded<\/span> <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">false<\/span><span style=\"color: #333333\">;<\/span>\r\n\t<span style=\"color: #888888\">\/\/set the stage<\/span>\r\n\tad<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">stage<\/span> <span style=\"color: #333333\">=<\/span> <span style=\"color: #008800; font-weight: bold\">this<\/span><span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">stage<\/span><span style=\"color: #333333\">;<\/span>\r\n\r\n\tad<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">addEventListener<\/span><span style=\"color: #333333\">(<\/span>StageAdEvent<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">AD_ACTION_COMPLETE<\/span><span style=\"color: #333333\">,<\/span>onActionCompleteHandler<span style=\"color: #333333\">);<\/span>\r\n\tad<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">addEventListener<\/span><span style=\"color: #333333\">(<\/span>StageAdEvent<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">AD_ACTION_START<\/span><span style=\"color: #333333\">,<\/span>onActionStartingHandler<span style=\"color: #333333\">);<\/span>\r\n\tad<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">addEventListener<\/span><span style=\"color: #333333\">(<\/span>StageAdEvent<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">AD_LOAD_COMPLETE<\/span><span style=\"color: #333333\">,<\/span>onAdLoadCompleteHandler<span style=\"color: #333333\">);<\/span>\r\n\tad<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">addEventListener<\/span><span style=\"color: #333333\">(<\/span>StageAdEvent<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">AD_LOAD_FAIL<\/span><span style=\"color: #333333\">,<\/span>onAdLoadFailHandler<span style=\"color: #333333\">);<\/span>\r\n\tad<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">addEventListener<\/span><span style=\"color: #333333\">(<\/span>StageAdEvent<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">AD_UNLOAD<\/span><span style=\"color: #333333\">,<\/span>onAdUnloadHandler<span style=\"color: #333333\">);<\/span>\r\n\r\n\t<span style=\"color: #888888\">\/\/placement - default is bottom<\/span>\r\n\t<span style=\"color: #888888\">\/\/ad.align = StageAdAlign.BOTTOM;<\/span>\r\n\t<span style=\"color: #888888\">\/\/ad.align = StageAdAlign.TOP;<\/span>\r\n\r\n\t<span style=\"color: #888888\">\/\/to unload set it to null<\/span>\r\n\t<span style=\"color: #888888\">\/\/ad instance gets disposed once ad gets loaded on the screen and cancelled by the user<\/span>\r\n\t<span style=\"color: #888888\">\/\/ad.stage = null;<\/span>\r\n\r\n\t<span style=\"color: #0066BB; font-weight: bold\">trace<\/span><span style=\"color: #333333\">(<\/span><span style=\"background-color: #fff0f0\">&quot;iad init&quot;<\/span><span style=\"color: #333333\">);<\/span>\r\n\r\n<span style=\"color: #333333\">}<\/span>\r\n<span style=\"color: #008800; font-weight: bold\">else<\/span>\r\n<span style=\"color: #333333\">{<\/span>\r\n\r\n\t<span style=\"color: #0066BB; font-weight: bold\">trace<\/span><span style=\"color: #333333\">(<\/span><span style=\"background-color: #fff0f0\">&quot;StageBannerAd.isSupported=false&quot;<\/span><span style=\"color: #333333\">);<\/span>\r\n\r\n\r\n<span style=\"color: #333333\">}<\/span>\r\n<\/pre>\n<\/div>\n<p>To remove an ad set the instance to null: <em>ad.stage = null;<\/em><br \/>\nFrom what I read, you do not need to remove listeners. It gets fully disposed of once it is cancelled by the user (<a href=\"http:\/\/forums.adobe.com\/thread\/1339819\" target=\"_blank\">SOURCE<\/a>).<\/p>\n<p>Alternatively, this is a <strong>fullscreen ad<\/strong>:<br \/>\nIt\u2019s basically the same except you create a: <em>var fullscreenAd:StageFullscreenAd;<\/em><br \/>\nAnd check for:<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%\"><span style=\"color: #008800; font-weight: bold\">var<\/span> fullscreenAd:<span style=\"color: #333399; font-weight: bold\">StageFullscreenAd<\/span><span style=\"color: #333333\">;<\/span>\r\n\r\n<span style=\"color: #888888\">\/\/Fullscreen advertisements from the iAd network (fullscreen ads are supported on iPad devices only). <\/span>\r\n<span style=\"color: #888888\">\/\/https:\/\/developer.apple.com\/library\/ios\/documentation\/userexperience\/conceptual\/iAd_Guide\/Full-ScreenAdvertisements\/Full-ScreenAdvertisements.html<\/span>\r\n<span style=\"color: #888888\">\/\/Fullscreen<\/span>\r\n<span style=\"color: #008800; font-weight: bold\">if<\/span> <span style=\"color: #333333\">(<\/span>StageFullscreenAd<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">isSupported<\/span><span style=\"color: #333333\">)<\/span>\r\n<span style=\"color: #333333\">{<\/span>\r\n\t<span style=\"color: #888888\">\/\/<\/span>\r\n\tfullscreenAd<span style=\"color: #333333\">=<\/span><span style=\"color: #008800; font-weight: bold\">new<\/span> <span style=\"color: #333399; font-weight: bold\">StageFullscreenAd<\/span><span style=\"color: #333333\">();<\/span>\r\n\tfullscreenAd<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">addToStage<\/span><span style=\"color: #333333\">();<\/span>\r\n\t<span style=\"color: #888888\">\/\/<\/span>\r\n\tfullscreenAd<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">addEventListener<\/span><span style=\"color: #333333\">(<\/span>StageAdEvent<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">AD_ACTION_COMPLETE<\/span><span style=\"color: #333333\">,<\/span>onActionCompleteHandler<span style=\"color: #333333\">);<\/span>\r\n\tfullscreenAd<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">addEventListener<\/span><span style=\"color: #333333\">(<\/span>StageAdEvent<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">AD_ACTION_START<\/span><span style=\"color: #333333\">,<\/span>onActionStartingHandler<span style=\"color: #333333\">);<\/span>\r\n\tfullscreenAd<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">addEventListener<\/span><span style=\"color: #333333\">(<\/span>StageAdEvent<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">AD_LOAD_COMPLETE<\/span><span style=\"color: #333333\">,<\/span>onAdLoadCompleteHandler<span style=\"color: #333333\">);<\/span>\r\n\tfullscreenAd<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">addEventListener<\/span><span style=\"color: #333333\">(<\/span>StageAdEvent<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">AD_LOAD_FAIL<\/span><span style=\"color: #333333\">,<\/span>onAdLoadFailHandler<span style=\"color: #333333\">);<\/span>\r\n\tfullscreenAd<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">addEventListener<\/span><span style=\"color: #333333\">(<\/span>StageAdEvent<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">AD_UNLOAD<\/span><span style=\"color: #333333\">,<\/span>onAdUnloadHandler<span style=\"color: #333333\">);<\/span>\r\n\t<span style=\"color: #888888\">\/\/<\/span>\r\n<span style=\"color: #333333\">}<\/span>\r\n<span style=\"color: #008800; font-weight: bold\">else<\/span>\r\n<span style=\"color: #333333\">{<\/span>\r\n\t<span style=\"color: #0066BB; font-weight: bold\">trace<\/span><span style=\"color: #333333\">(<\/span><span style=\"background-color: #fff0f0\">&quot;stageFullscreenAd.isSupported=false&quot;<\/span><span style=\"color: #333333\">);<\/span>\r\n<span style=\"color: #333333\">}<\/span>\r\n<\/pre>\n<\/div>\n<p>Note that fullscreen ads are <em>only supported on iPad<\/em>.<\/p>\n<p>If it\u2019s working you will see a fake \u201cwelcome\u201d ad by Apple.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/nathalielawhead.com\/sourcefiles\/StageAd_iAd_WorkingExample\/stageAd_itWorks.png\" alt=\"\" \/><\/p>\n<p>And that\u2019s stageAd.<br \/>\nSourcefiles here: <a href=\"http:\/\/nathalielawhead.com\/sourcefiles\/StageAd_iAd_WorkingExample\/\" target=\"_blank\">http:\/\/nathalielawhead.com\/sourcefiles\/StageAd_iAd_WorkingExample\/<\/a><\/p>\n<p><em><strong>iAd EXAMPLE<\/strong><\/em><\/p>\n<p>iAd is another one. It\u2019s free. So here it is&#8230;<br \/>\nLink: <a href=\"http:\/\/code.google.com\/p\/iad-ane-for-flash-air-mobile-ios\/\" target=\"_blank\">http:\/\/code.google.com\/p\/iad-ane-for-flash-air-mobile-ios\/<\/a><br \/>\nANE here: <a href=\"http:\/\/code.google.com\/p\/iad-ane-for-flash-air-mobile-ios\/source\/browse\/#svn%2Ftrunk%2Fane\" target=\"_blank\">http:\/\/code.google.com\/p\/iad-ane-for-flash-air-mobile-ios\/source\/browse\/#svn%2Ftrunk%2Fane<\/a><br \/>\nDownload Source Here: <a href=\"http:\/\/nathalielawhead.com\/sourcefiles\/StageAd_iAd_WorkingExample\/iad-ane_Example\/\" target=\"_blank\">http:\/\/nathalielawhead.com\/sourcefiles\/StageAd_iAd_WorkingExample\/iad-ane_Example\/<\/a><\/p>\n<p>Start a new AIR for iOS project.<br \/>\nBrowse to the ANE, as described above.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%\"><span style=\"color: #008800; font-weight: bold\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold\">so.cuo.platform.iad.<\/span><span style=\"color: #333333\">*;<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold\">if<\/span> <span style=\"color: #333333\">(<\/span>IAd<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">getInstance<\/span><span style=\"color: #333333\">().<\/span>supportDevice<span style=\"color: #333333\">)<\/span>\r\n<span style=\"color: #333333\">{<\/span>\r\n\tIAd<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">getInstance<\/span><span style=\"color: #333333\">().<\/span>showBanner<span style=\"color: #333333\">(<\/span>IAd<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">BANNER<\/span><span style=\"color: #333333\">,<\/span>IAdPosition<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">BOTTOM_CENTER<\/span><span style=\"color: #333333\">);<\/span>\r\n<span style=\"color: #333333\">}<\/span>\r\n\r\n<span style=\"color: #888888\">\/\/ Check ane support. Apple does not provide Interstitial ad on iphone.;<\/span>\r\n<span style=\"color: #008800; font-weight: bold\">if<\/span> <span style=\"color: #333333\">(<\/span>IAd<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">getInstance<\/span><span style=\"color: #333333\">().<\/span>supportDevice <span style=\"color: #333333\">&amp;&amp;<\/span> IAd<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">getInstance<\/span><span style=\"color: #333333\">().<\/span>supportedInterstitial<span style=\"color: #333333\">)<\/span>\r\n<span style=\"color: #333333\">{<\/span>\r\n\tIAd<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">getInstance<\/span><span style=\"color: #333333\">().<\/span>addEventListener<span style=\"color: #333333\">(<\/span>IAdEvent<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">onInterstitialReceive<\/span><span style=\"color: #333333\">,<\/span>onAdReceived<span style=\"color: #333333\">);<\/span>\r\n\tIAd<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">getInstance<\/span><span style=\"color: #333333\">().<\/span>cacheInterstitial<span style=\"color: #333333\">();<\/span>\r\n<span style=\"color: #333333\">}<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold\">function <\/span><span style=\"color: #0066BB; font-weight: bold\">onAdReceived<\/span><span style=\"color: #333333\">(<\/span>event<span style=\"color: #333333\">:<\/span><span style=\"color: #333399; font-weight: bold\">IAdEvent<\/span><span style=\"color: #333333\">)<\/span>\r\n<span style=\"color: #333333\">{<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold\">if<\/span> <span style=\"color: #333333\">(<\/span>event<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">type<\/span> <span style=\"color: #333333\">==<\/span> IAdEvent<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">onInterstitialReceive<\/span><span style=\"color: #333333\">)<\/span>\r\n\t<span style=\"color: #333333\">{<\/span>\r\n\t\tIAd<span style=\"color: #333333\">.<\/span><span style=\"color: #0000CC\">getInstance<\/span><span style=\"color: #333333\">().<\/span>showInterstitial<span style=\"color: #333333\">();<\/span>\r\n\t<span style=\"color: #333333\">}<\/span>\r\n<span style=\"color: #333333\">}<\/span>\r\n<\/pre>\n<\/div>\n<p>Download Source Here: <a href=\"http:\/\/nathalielawhead.com\/sourcefiles\/StageAd_iAd_WorkingExample\/iad-ane_Example\/\" target=\"_blank\">http:\/\/nathalielawhead.com\/sourcefiles\/StageAd_iAd_WorkingExample\/iad-ane_Example\/<\/a><\/p>\n<p><strong>CONCLUSION<\/strong><\/p>\n<p>I wrote this walkthrough to help people starting out. I will be building on it as I find more information, and adding more examples. Perhaps this will grow into a reliable reference as things unfold.<br \/>\nHope this helps, good luck!<\/p>\n<p>If you found this helpful maybe you will enjoy <a href=\"http:\/\/www.nathalielawhead.com\/candybox\/making-an-adobe-air-ios-app-flash-xcode-and-submitting-from-itunes-connect-walkthrough\" target=\"_blank\">Making an App: Adobe AIR for iOS \u2013 Flash to iOS Walkthrough<\/a>. It will guide you through the setup, and development process of an AIR app (as well as getting started with Apple Developer, certificates, etc)&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sourcefiles for the tutorials are here. SUMMARY It can be very confusing to know where to start when you want to add advertisements in your Flash\/AIR based iOS app. Google search results can be ambiguous at best, and there are a number of free solutions out there, but little or no support. The most recommended pay for solution is Milkman Games\u2019s iAd for iOS Extension. There are also a number of others (like Smaato For Android and iOS ) for pay, but I\u2019m a firm believer in that \u201cif they do it, I should be able to do it too\u201d.&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":4522,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[12],"tags":[],"class_list":["post-3009","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-resources"],"_links":{"self":[{"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/posts\/3009","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/comments?post=3009"}],"version-history":[{"count":11,"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/posts\/3009\/revisions"}],"predecessor-version":[{"id":3020,"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/posts\/3009\/revisions\/3020"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/media\/4522"}],"wp:attachment":[{"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/media?parent=3009"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/categories?post=3009"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.nathalielawhead.com\/candybox\/wp-json\/wp\/v2\/tags?post=3009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}