tags:

views:

131

answers:

0

Hi,

I'm using OpenX to serve ads on my Flex website.

It serves ads when I use my Mac with Safari or Firefox. But, it doesn't work when I checked my site on two PCs both running Windows XP with IE and Firefox. I'm getting error #1090, which is "XML parser Failure: element is malformed" only on the PCs, not on the Mac. In order to use OpenX, the ads have to be properly formatted. Thank you Daryl Bowden for creating the class below:

package com.darylbowden.ads
{
     import flash.external.ExternalInterface;
     import mx.controls.Alert;

    public class OpenAds {

      private static var externalCallback:String = "callOpenAds";
      private static var retries:uint = 10;

      public function OpenAds(){ 
      }

      public function getAdReturn():Ad {
       var xmlReturn:XML;
       if(ExternalInterface.available) {
        var adReturn:String = ExternalInterface.call(externalCallback);

          try

          {
          adReturn = adReturn.replace("//]]>->","//]]>->\n");
          var infoTagsIndex:int = adReturn.indexOf('<script type="text/javascript" src=""', 0);
          adReturn = adReturn.substring(infoTagsIndex, adReturn.length);
          var wasFlash:Boolean = false;
           if(adReturn.search("<embed") == -1) {
            adReturn = adReturn.replace('></a>', '></img></a>');
            adReturn = adReturn.replace('></div>', '></img></div>');
           }
           else {
            adReturn = adReturn.replace('></div>\n<script','></embed></div>\n<script');
            adReturn = adReturn.replace('></div>\n<noscript','></img></div>\n<noscript');
            wasFlash = true;
           }

         adReturn = '<adXMLReturn>' + adReturn + '</adXMLReturn>';
         xmlReturn = new XML(adReturn);

         var ad:Ad;

           if(wasFlash){
            ad = new Ad(xmlReturn, true);
           }
           else {
            ad = new Ad(xmlReturn);
           }
         }
         catch(error:Error){
          Alert.show(error.message + 'stacktrace:' + error.getStackTrace(), "Error"); 
         }
       }
        else {
        Alert.show("Javascript must be enabled to view this page properly.", "Javascript Not Detected");
        xmlReturn = new XML('<root>xml</root>');
       } 
        return ad; 
       }

    } 



}

I've got a catch statement sending the error. Does anyone know why it doesn't work on PCs? Any suggestions on how to solve this problem? I'm pretty desperate. I've also posted this question on OpenX's forum, but not too many people use Flex over there.

Thank you.

-Laxmidi