Help with iAds code

Hi all,

I’m using the code below to display iAds at the top of my screen and disable them when it detects the ‘End iAds’ gameobject.

But I am having a couple of problems:

  1.  If a banner doesn't load, the app crashes when it tries to run banner.Hide();
  2.  When the test banner does load and it tries to refresh, if it does not receive a refreshed ad i just get a white banner across the    
      top of my screen. and the banner.Hide(); command doesn't remove it.
     ////////  CODE  ////////
     #pragma strict
     private var banner : ADBannerView = null;
     function Start () {
     		banner = new ADBannerView();
             banner.autoSize = true;
             banner.autoPosition = ADPosition.Top;
     function ShowBanner () {
         yield WaitForSeconds (2.0f);
     function ShowBanner2() {
         while (!banner.loaded && banner.error == null)
         if (banner.error == null)
         else banner = null;
     function Update () {
     if (GameObject.Find("End iAds") != null)
     ////////  END CODE ////////

Any help would be appreciated.



As per the comment section, this question has already been “answered”, so I’ll post my advice as an answer, so we can get this off the unanswered page :wink:

When skimming through your code, you continually check for errors in your banner. Everywhere except in the Update function. Most likely, you are trying to call banner.Hide, when the banner has an error, or has not loaded yet. This shouldn’t cause a crash, but none the less it’s still a problem.

Hope this helps,