kyberno 0 Newbie Poster

Greetings...!

I have this admob code in a class file:

package
{
    import flash.events.MouseEvent;
    import flash.display.MovieClip;
    import flash.system.System;
    import flash.system.Capabilities;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.desktop.NativeApplication;
    import flash.utils.setTimeout;

    import com.hdi.nativeExtensions.NativeAds;
    import com.hdi.nativeExtensions.NativeAdsEvent; 


    public class Main extends MovieClip {       
        public var na : NativeApplication;
        private var admobId:String = 'a1514b5ef85e336';


        public function Main()      
        {
            na = NativeApplication.nativeApplication;
            na.addEventListener('exiting',exit,false,0,true);
            na.addEventListener('deactivate',exit,false,0,true);

            if ( stage ){
                stage.scaleMode = 'noScale';
                stage.align = 'TL';
            }           
            if ( loaderInfo ){
                loaderInfo.addEventListener( Event.INIT, init, false, 0, true );
            } else {
                init(null);
            }
        }


        public function exit ( e:* = null ):void
        {
            NativeAds.deactivateAd();
            setTimeout(finalExit,250);          
        }


        private function finalExit():void
        {
            na.exit();
        }


        public function showAd():void
        {
            NativeAds.dispatcher.addEventListener(NativeAdsEvent.AD_RECEIVED,onAdReceived);
            NativeAds.showAd(160,1,480,75);
        }


        public function hideAd():void
        {
            NativeAds.hideAd();
        }


        public function onAdReceived(e:* = null):void
        {
            trace("update ui's size and position");
        }


        private function init ( e:* ):void
        {
            NativeAds.setUnitId(admobId);
            NativeAds.setAdMode(true);
            NativeAds.initAd(0,0, 320, 50);         
            showAd();
        }
    }
}

...and at the end of the timeline i have this AS3 code for loading another swf file:

var _swfLoader:Loader;
var _swfContent:MovieClip;

loadSWF("MainA.swf");

function loadSWF(path:String):void {
   var _req:URLRequest = new URLRequest();
   _req.url = path;

   _swfLoader = new Loader();
   setupListeners(_swfLoader.contentLoaderInfo);

   _swfLoader.load(_req);
}

function setupListeners(dispatcher:IEventDispatcher):void {
   dispatcher.addEventListener(Event.COMPLETE, addSWF);
   dispatcher.addEventListener(ProgressEvent.PROGRESS, preloadSWF);
}

function preloadSWF(event:ProgressEvent):void {
   var _perc:int = (event.bytesLoaded / event.bytesTotal) * 100;
   // swfPreloader.percentTF.text = _perc + "%";
}

function addSWF(event:Event):void {
   event.target.removeEventListener(Event.COMPLETE, addSWF);
   event.target.removeEventListener(ProgressEvent.PROGRESS, preloadSWF);

   _swfContent = event.target.content;
   _swfContent.addEventListener("close", unloadSWF);

   addChild(_swfContent);
}

function unloadSWF(event:Event):void {
   _swfLoader.unloadAndStop();

removeChild(_swfContent);
   _swfContent = null;
}

...but there is a problem and i can't seem to be able to fix it... can you help me? i wouldn't mind changing the entire loading swf code...

Thanx!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.