home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Puzzle / filler.swf / scripts / com / mochi / MochiAd.as next >
Text File  |  2008-09-02  |  25KB  |  793 lines

  1. package com.mochi
  2. {
  3.    import flash.display.Loader;
  4.    import flash.display.MovieClip;
  5.    import flash.events.Event;
  6.    import flash.events.IOErrorEvent;
  7.    import flash.net.LocalConnection;
  8.    import flash.net.URLRequest;
  9.    import flash.net.URLRequestMethod;
  10.    import flash.net.URLVariables;
  11.    import flash.system.Security;
  12.    import flash.utils.getTimer;
  13.    import flash.utils.setTimeout;
  14.    
  15.    public class MochiAd
  16.    {
  17.        
  18.       
  19.       public function MochiAd()
  20.       {
  21.          super();
  22.       }
  23.       
  24.       public static function getVersion() : String
  25.       {
  26.          return "2.1";
  27.       }
  28.       
  29.       public static function showTimedAd(param1:Object) : void
  30.       {
  31.          MochiAd.showInterLevelAd(param1);
  32.       }
  33.       
  34.       public static function _allowDomains(param1:String) : String
  35.       {
  36.          var _loc2_:String = null;
  37.          _loc2_ = param1.split("/")[2].split(":")[0];
  38.          Security.allowDomain("*");
  39.          Security.allowDomain(_loc2_);
  40.          Security.allowInsecureDomain("*");
  41.          Security.allowInsecureDomain(_loc2_);
  42.          return _loc2_;
  43.       }
  44.       
  45.       public static function load(param1:Object) : MovieClip
  46.       {
  47.          var DEFAULTS:Object = null;
  48.          var clip:Object = null;
  49.          var depth:Number = NaN;
  50.          var mc:MovieClip = null;
  51.          var wh:Array = null;
  52.          var lv:URLVariables = null;
  53.          var k:String = null;
  54.          var server:String = null;
  55.          var hostname:String = null;
  56.          var lc:LocalConnection = null;
  57.          var name:String = null;
  58.          var loader:Loader = null;
  59.          var f:Function = null;
  60.          var g:Function = null;
  61.          var req:URLRequest = null;
  62.          var v:Object = null;
  63.          var options:Object = param1;
  64.          DEFAULTS = {
  65.             "server":"http://x.mochiads.com/srv/1/",
  66.             "method":"load",
  67.             "depth":10333,
  68.             "id":"_UNKNOWN_"
  69.          };
  70.          options = MochiAd._parseOptions(options,DEFAULTS);
  71.          options.swfv = 9;
  72.          options.mav = MochiAd.getVersion();
  73.          clip = options.clip;
  74.          if(!MochiAd._isNetworkAvailable())
  75.          {
  76.             return null;
  77.          }
  78.          if(clip._mochiad_loaded)
  79.          {
  80.             return null;
  81.          }
  82.          depth = options.depth;
  83.          delete options.depth;
  84.          mc = createEmptyMovieClip(clip,"_mochiad",depth);
  85.          wh = MochiAd._getRes(options,clip);
  86.          options.res = wh[0] + "x" + wh[1];
  87.          options.server += options.id;
  88.          delete options.id;
  89.          clip._mochiad_loaded = true;
  90.          if(clip.loaderInfo.loaderURL.indexOf("http") == 0)
  91.          {
  92.             options.as3_swf = clip.loaderInfo.loaderURL;
  93.          }
  94.          lv = new URLVariables();
  95.          for(k in options)
  96.          {
  97.             v = options[k];
  98.             if(!(v is Function))
  99.             {
  100.                lv[k] = v;
  101.             }
  102.          }
  103.          server = lv.server;
  104.          delete lv.server;
  105.          hostname = _allowDomains(server);
  106.          lc = new LocalConnection();
  107.          lc.client = mc;
  108.          name = ["",Math.floor(new Date().getTime()),Math.floor(Math.random() * 999999)].join("_");
  109.          lc.allowDomain("*","localhost");
  110.          lc.allowInsecureDomain("*","localhost");
  111.          lc.connect(name);
  112.          mc.lc = lc;
  113.          lv.lc = name;
  114.          lv.st = getTimer();
  115.          loader = new Loader();
  116.          f = function(param1:Object):void
  117.          {
  118.             mc._mochiad_ctr_failed = true;
  119.          };
  120.          loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,f);
  121.          g = function(param1:Object):void
  122.          {
  123.             MochiAd.unload(clip);
  124.          };
  125.          loader.contentLoaderInfo.addEventListener(Event.UNLOAD,g);
  126.          req = new URLRequest(server + ".swf");
  127.          req.contentType = "application/x-www-form-urlencoded";
  128.          req.method = URLRequestMethod.POST;
  129.          req.data = lv;
  130.          loader.load(req);
  131.          mc.addChild(loader);
  132.          mc._mochiad_ctr = loader;
  133.          return mc;
  134.       }
  135.       
  136.       public static function sendHighScore(param1:Object, param2:Object, param3:Object = null) : Boolean
  137.       {
  138.          var _loc4_:MovieClip = null;
  139.          if(!(_loc4_ = MochiAd._loadCommunicator({
  140.             "clip":param1.clip,
  141.             "id":param1.id
  142.          })))
  143.          {
  144.             return false;
  145.          }
  146.          _loc4_.doSend(["sendHighScore",param1],param2,param3);
  147.          return true;
  148.       }
  149.       
  150.       public static function _parseOptions(param1:Object, param2:Object) : Object
  151.       {
  152.          var _loc3_:Object = null;
  153.          var _loc4_:* = null;
  154.          var _loc5_:Array = null;
  155.          var _loc6_:Number = NaN;
  156.          var _loc7_:Array = null;
  157.          _loc3_ = {};
  158.          for(_loc4_ in param2)
  159.          {
  160.             _loc3_[_loc4_] = param2[_loc4_];
  161.          }
  162.          if(param1)
  163.          {
  164.             for(_loc4_ in param1)
  165.             {
  166.                _loc3_[_loc4_] = param1[_loc4_];
  167.             }
  168.          }
  169.          param1 = _loc3_.clip.loaderInfo.parameters.mochiad_options;
  170.          if(param1)
  171.          {
  172.             _loc5_ = param1.split("&");
  173.             _loc6_ = 0;
  174.             while(_loc6_ < _loc5_.length)
  175.             {
  176.                _loc7_ = _loc5_[_loc6_].split("=");
  177.                _loc3_[unescape(_loc7_[0])] = unescape(_loc7_[1]);
  178.                _loc6_++;
  179.             }
  180.          }
  181.          return _loc3_;
  182.       }
  183.       
  184.       public static function _isNetworkAvailable() : Boolean
  185.       {
  186.          return Security.sandboxType != "localWithFile";
  187.       }
  188.       
  189.       public static function unload(param1:Object) : Boolean
  190.       {
  191.          if(param1.clip && param1.clip._mochiad)
  192.          {
  193.             param1 = param1.clip;
  194.          }
  195.          if(!param1._mochiad)
  196.          {
  197.             return false;
  198.          }
  199.          if(param1._mochiad.onUnload)
  200.          {
  201.             param1._mochiad.onUnload();
  202.          }
  203.          param1.removeChild(param1._mochiad);
  204.          delete param1._mochiad_loaded;
  205.          delete param1._mochiad;
  206.          return true;
  207.       }
  208.       
  209.       public static function showInterLevelAd(param1:Object) : void
  210.       {
  211.          var DEFAULTS:Object = null;
  212.          var clip:Object = null;
  213.          var ad_msec:Number = NaN;
  214.          var ad_timeout:Number = NaN;
  215.          var fadeout_time:Number = NaN;
  216.          var mc:MovieClip = null;
  217.          var wh:Array = null;
  218.          var w:Number = NaN;
  219.          var h:Number = NaN;
  220.          var chk:MovieClip = null;
  221.          var options:Object = param1;
  222.          DEFAULTS = {
  223.             "ad_timeout":2000,
  224.             "fadeout_time":250,
  225.             "regpt":"o",
  226.             "method":"showTimedAd",
  227.             "ad_started":function():void
  228.             {
  229.                this.clip.stop();
  230.             },
  231.             "ad_finished":function():void
  232.             {
  233.                this.clip.play();
  234.             }
  235.          };
  236.          options = MochiAd._parseOptions(options,DEFAULTS);
  237.          clip = options.clip;
  238.          ad_msec = 11000;
  239.          ad_timeout = options.ad_timeout;
  240.          delete options.ad_timeout;
  241.          fadeout_time = options.fadeout_time;
  242.          delete options.fadeout_time;
  243.          if(!MochiAd.load(options))
  244.          {
  245.             options.ad_finished();
  246.             return;
  247.          }
  248.          options.ad_started();
  249.          mc = clip._mochiad;
  250.          mc["onUnload"] = function():void
  251.          {
  252.             options.ad_finished();
  253.          };
  254.          wh = MochiAd._getRes(options,clip);
  255.          w = wh[0];
  256.          h = wh[1];
  257.          mc.x = w * 0.5;
  258.          mc.y = h * 0.5;
  259.          chk = createEmptyMovieClip(mc,"_mochiad_wait",3);
  260.          chk.ad_msec = ad_msec;
  261.          chk.ad_timeout = ad_timeout;
  262.          chk.started = getTimer();
  263.          chk.showing = false;
  264.          chk.fadeout_time = fadeout_time;
  265.          chk.fadeFunction = function():void
  266.          {
  267.             var _loc1_:Number = NaN;
  268.             _loc1_ = 100 * (1 - (getTimer() - this.fadeout_start) / this.fadeout_time);
  269.             if(_loc1_ > 0)
  270.             {
  271.                this.parent.alpha = _loc1_ * 0.01;
  272.             }
  273.             else
  274.             {
  275.                MochiAd.unload(clip);
  276.                delete this["onEnterFrame"];
  277.             }
  278.          };
  279.          mc.unloadAd = function():void
  280.          {
  281.             MochiAd.unload(clip);
  282.          };
  283.          mc.adjustProgress = function(param1:Number):void
  284.          {
  285.             var _loc2_:Object = null;
  286.             _loc2_ = mc._mochiad_wait;
  287.             _loc2_.server_control = true;
  288.             _loc2_.started = getTimer();
  289.             _loc2_.ad_msec = param1 - 250;
  290.          };
  291.          chk["onEnterFrame"] = function():void
  292.          {
  293.             var _loc1_:Object = null;
  294.             var _loc2_:Number = NaN;
  295.             var _loc3_:Boolean = false;
  296.             var _loc4_:Number = NaN;
  297.             _loc1_ = this.parent._mochiad_ctr;
  298.             _loc2_ = getTimer() - this.started;
  299.             _loc3_ = false;
  300.             if(!chk.showing)
  301.             {
  302.                if((_loc4_ = _loc1_.loaderInfo.bytesTotal) > 0 || "number" == "undefined")
  303.                {
  304.                   chk.showing = true;
  305.                   chk.started = getTimer();
  306.                }
  307.                else if(_loc2_ > chk.ad_timeout)
  308.                {
  309.                   _loc3_ = true;
  310.                }
  311.             }
  312.             if(_loc2_ > chk.ad_msec || this.parent._mochiad_ctr_failed)
  313.             {
  314.                _loc3_ = true;
  315.             }
  316.             if(_loc3_)
  317.             {
  318.                if(this.server_control)
  319.                {
  320.                   delete this.onEnterFrame;
  321.                }
  322.                else
  323.                {
  324.                   this.fadeout_start = getTimer();
  325.                   this.onEnterFrame = this.fadeFunction;
  326.                }
  327.             }
  328.          };
  329.          doOnEnterFrame(chk);
  330.       }
  331.       
  332.       public static function _getRes(param1:Object, param2:Object) : Array
  333.       {
  334.          var _loc3_:Object = null;
  335.          var _loc4_:Number = NaN;
  336.          var _loc5_:Number = NaN;
  337.          var _loc6_:Array = null;
  338.          _loc3_ = param2.getBounds(param2.root);
  339.          _loc4_ = 0;
  340.          _loc5_ = 0;
  341.          if(typeof param1.res != "undefined")
  342.          {
  343.             _loc6_ = param1.res.split("x");
  344.             _loc4_ = parseFloat(_loc6_[0]);
  345.             _loc5_ = parseFloat(_loc6_[1]);
  346.          }
  347.          else
  348.          {
  349.             _loc4_ = _loc3_.xMax - _loc3_.xMin;
  350.             _loc5_ = _loc3_.yMax - _loc3_.yMin;
  351.          }
  352.          if(_loc4_ == 0 || _loc5_ == 0)
  353.          {
  354.             _loc4_ = param2.stage.stageWidth;
  355.             _loc5_ = param2.stage.stageHeight;
  356.          }
  357.          return [_loc4_,_loc5_];
  358.       }
  359.       
  360.       public static function createEmptyMovieClip(param1:Object, param2:String, param3:Number) : MovieClip
  361.       {
  362.          var _loc4_:MovieClip = null;
  363.          _loc4_ = new MovieClip();
  364.          if(false && param3)
  365.          {
  366.             param1.addChildAt(_loc4_,param3);
  367.          }
  368.          else
  369.          {
  370.             param1.addChild(_loc4_);
  371.          }
  372.          param1[param2] = _loc4_;
  373.          _loc4_["_name"] = param2;
  374.          return _loc4_;
  375.       }
  376.       
  377.       public static function _loadCommunicator(param1:Object) : MovieClip
  378.       {
  379.          var DEFAULTS:Object = null;
  380.          var clip:Object = null;
  381.          var clipname:String = null;
  382.          var server:String = null;
  383.          var depth:Number = NaN;
  384.          var mc:MovieClip = null;
  385.          var lv:URLVariables = null;
  386.          var k:String = null;
  387.          var lc:LocalConnection = null;
  388.          var name:String = null;
  389.          var req:URLRequest = null;
  390.          var loader:Loader = null;
  391.          var options:Object = param1;
  392.          DEFAULTS = {
  393.             "com_server":"http://x.mochiads.com/com/1/",
  394.             "method":"loadCommunicator",
  395.             "depth":10337,
  396.             "id":"_UNKNOWN_"
  397.          };
  398.          options = MochiAd._parseOptions(options,DEFAULTS);
  399.          options.swfv = 9;
  400.          options.mav = MochiAd.getVersion();
  401.          clip = options.clip;
  402.          clipname = "_mochiad_com_" + options.id;
  403.          if(!MochiAd._isNetworkAvailable())
  404.          {
  405.             return null;
  406.          }
  407.          if(clip[clipname])
  408.          {
  409.             return clip[clipname];
  410.          }
  411.          server = options.com_server + options.id;
  412.          MochiAd._allowDomains(server);
  413.          delete options.id;
  414.          delete options.com_server;
  415.          depth = options.depth;
  416.          delete options.depth;
  417.          mc = createEmptyMovieClip(clip,clipname,depth);
  418.          lv = new URLVariables();
  419.          for(k in options)
  420.          {
  421.             lv[k] = options[k];
  422.          }
  423.          lc = new LocalConnection();
  424.          lc.client = mc;
  425.          name = ["",Math.floor(new Date().getTime()),Math.floor(Math.random() * 999999)].join("_");
  426.          lc.allowDomain("*","localhost");
  427.          lc.allowInsecureDomain("*","localhost");
  428.          lc.connect(name);
  429.          mc.name = name;
  430.          mc.lc = lc;
  431.          lv.lc = name;
  432.          mc._id = 0;
  433.          mc._queue = [];
  434.          mc.rpcResult = function(param1:Object):void
  435.          {
  436.             var _loc3_:Array = null;
  437.             var _loc4_:Array = null;
  438.             var _loc5_:Number = NaN;
  439.             var _loc6_:Object = null;
  440.             var _loc7_:Object = null;
  441.             param1 = parseInt(param1.toString());
  442.             _loc3_ = mc._callbacks[param1];
  443.             if(typeof _loc3_ == "undefined")
  444.             {
  445.                return;
  446.             }
  447.             delete mc._callbacks[param1];
  448.             _loc4_ = [];
  449.             _loc5_ = 2;
  450.             while(_loc5_ < _loc3_.length)
  451.             {
  452.                _loc4_.push(_loc3_[_loc5_]);
  453.                _loc5_++;
  454.             }
  455.             _loc5_ = 1;
  456.             while(_loc5_ < arguments.length)
  457.             {
  458.                _loc4_.push(arguments[_loc5_]);
  459.                _loc5_++;
  460.             }
  461.             _loc6_ = _loc3_[1];
  462.             if((_loc7_ = _loc3_[0]) && typeof _loc6_ == "string")
  463.             {
  464.                _loc6_ = _loc7_[_loc6_];
  465.             }
  466.             if(typeof _loc6_ == "function")
  467.             {
  468.                _loc6_.apply(_loc7_,_loc4_);
  469.             }
  470.          };
  471.          mc._didConnect = function(param1:String):void
  472.          {
  473.             var _loc2_:Array = null;
  474.             var _loc3_:Function = null;
  475.             var _loc4_:Number = NaN;
  476.             var _loc5_:Array = null;
  477.             mc._endpoint = param1;
  478.             _loc2_ = mc._queue;
  479.             delete mc._queue;
  480.             _loc3_ = mc.doSend;
  481.             _loc4_ = 0;
  482.             while(_loc4_ < _loc2_.length)
  483.             {
  484.                _loc5_ = _loc2_[_loc4_];
  485.                _loc3_.apply(this,_loc5_);
  486.                _loc4_++;
  487.             }
  488.          };
  489.          mc.doSend = function(param1:Array, param2:Object, param3:Object):void
  490.          {
  491.             var _loc5_:Number = NaN;
  492.             var _loc6_:LocalConnection = null;
  493.             var _loc7_:Array = null;
  494.             var _loc8_:Number = NaN;
  495.             if(mc._endpoint == null)
  496.             {
  497.                _loc7_ = [];
  498.                _loc8_ = 0;
  499.                while(_loc8_ < arguments.length)
  500.                {
  501.                   _loc7_.push(arguments[_loc8_]);
  502.                   _loc8_++;
  503.                }
  504.                mc._queue.push(_loc7_);
  505.                return;
  506.             }
  507.             mc._id += 1;
  508.             _loc5_ = mc._id;
  509.             mc._callbacks[_loc5_] = [param2,param3 || param2];
  510.             (_loc6_ = new LocalConnection()).send(mc._endpoint,"rpc",_loc5_,param1);
  511.          };
  512.          mc._callbacks = {};
  513.          mc._callbacks[0] = [mc,"_didConnect"];
  514.          lv.st = getTimer();
  515.          req = new URLRequest(server + ".swf");
  516.          req.contentType = "application/x-www-form-urlencoded";
  517.          req.method = URLRequestMethod.POST;
  518.          req.data = lv;
  519.          loader = new Loader();
  520.          loader.load(req);
  521.          mc.addChild(loader);
  522.          mc._mochiad_com = loader;
  523.          return mc;
  524.       }
  525.       
  526.       public static function showPreGameAd(param1:Object) : void
  527.       {
  528.          var DEFAULTS:Object = null;
  529.          var clip:Object = null;
  530.          var ad_msec:Number = NaN;
  531.          var ad_timeout:Number = NaN;
  532.          var fadeout_time:Number = NaN;
  533.          var mc:MovieClip = null;
  534.          var wh:Array = null;
  535.          var w:Number = NaN;
  536.          var h:Number = NaN;
  537.          var chk:MovieClip = null;
  538.          var bar:MovieClip = null;
  539.          var bar_color:Number = NaN;
  540.          var bar_background:Number = NaN;
  541.          var bar_outline:Number = NaN;
  542.          var backing_mc:MovieClip = null;
  543.          var backing:Object = null;
  544.          var inside_mc:MovieClip = null;
  545.          var inside:Object = null;
  546.          var outline_mc:MovieClip = null;
  547.          var outline:Object = null;
  548.          var complete:Boolean = false;
  549.          var unloaded:Boolean = false;
  550.          var f:Function = null;
  551.          var r:MovieClip = null;
  552.          var options:Object = param1;
  553.          DEFAULTS = {
  554.             "ad_timeout":3000,
  555.             "fadeout_time":250,
  556.             "regpt":"o",
  557.             "method":"showPreloaderAd",
  558.             "color":16747008,
  559.             "background":16777161,
  560.             "outline":13994812,
  561.             "ad_started":function():void
  562.             {
  563.                this.clip.stop();
  564.             },
  565.             "ad_finished":function():void
  566.             {
  567.                this.clip.play();
  568.             }
  569.          };
  570.          options = MochiAd._parseOptions(options,DEFAULTS);
  571.          clip = options.clip;
  572.          ad_msec = 11000;
  573.          ad_timeout = options.ad_timeout;
  574.          delete options.ad_timeout;
  575.          fadeout_time = options.fadeout_time;
  576.          delete options.fadeout_time;
  577.          if(!MochiAd.load(options))
  578.          {
  579.             options.ad_finished();
  580.             return;
  581.          }
  582.          options.ad_started();
  583.          mc = clip._mochiad;
  584.          mc["onUnload"] = function():void
  585.          {
  586.             var fn:Function = null;
  587.             fn = function():void
  588.             {
  589.                options.ad_finished();
  590.             };
  591.             setTimeout(fn,100);
  592.          };
  593.          wh = MochiAd._getRes(options,clip);
  594.          w = wh[0];
  595.          h = wh[1];
  596.          mc.x = w * 0.5;
  597.          mc.y = h * 0.5;
  598.          chk = createEmptyMovieClip(mc,"_mochiad_wait",3);
  599.          chk.x = w * -0.5;
  600.          chk.y = h * -0.5;
  601.          bar = createEmptyMovieClip(chk,"_mochiad_bar",4);
  602.          bar.x = 10;
  603.          bar.y = h - 20;
  604.          bar_color = options.color;
  605.          delete options.color;
  606.          bar_background = options.background;
  607.          delete options.background;
  608.          bar_outline = options.outline;
  609.          delete options.outline;
  610.          backing_mc = createEmptyMovieClip(bar,"_outline",1);
  611.          backing = backing_mc.graphics;
  612.          backing.beginFill(bar_background);
  613.          backing.moveTo(0,0);
  614.          backing.lineTo(w - 20,0);
  615.          backing.lineTo(w - 20,10);
  616.          backing.lineTo(0,10);
  617.          backing.lineTo(0,0);
  618.          backing.endFill();
  619.          inside_mc = createEmptyMovieClip(bar,"_inside",2);
  620.          inside = inside_mc.graphics;
  621.          inside.beginFill(bar_color);
  622.          inside.moveTo(0,0);
  623.          inside.lineTo(w - 20,0);
  624.          inside.lineTo(w - 20,10);
  625.          inside.lineTo(0,10);
  626.          inside.lineTo(0,0);
  627.          inside.endFill();
  628.          inside_mc.scaleX = 0;
  629.          outline_mc = createEmptyMovieClip(bar,"_outline",3);
  630.          outline = outline_mc.graphics;
  631.          outline.lineStyle(0,bar_outline,100);
  632.          outline.moveTo(0,0);
  633.          outline.lineTo(w - 20,0);
  634.          outline.lineTo(w - 20,10);
  635.          outline.lineTo(0,10);
  636.          outline.lineTo(0,0);
  637.          chk.ad_msec = ad_msec;
  638.          chk.ad_timeout = ad_timeout;
  639.          chk.started = getTimer();
  640.          chk.showing = false;
  641.          chk.last_pcnt = 0;
  642.          chk.fadeout_time = fadeout_time;
  643.          chk.fadeFunction = function():void
  644.          {
  645.             var _loc1_:Number = NaN;
  646.             _loc1_ = 100 * (1 - (getTimer() - this.fadeout_start) / this.fadeout_time);
  647.             if(_loc1_ > 0)
  648.             {
  649.                this.parent.alpha = _loc1_ * 0.01;
  650.             }
  651.             else
  652.             {
  653.                MochiAd.unload(clip);
  654.                delete this["onEnterFrame"];
  655.             }
  656.          };
  657.          complete = false;
  658.          unloaded = false;
  659.          f = function(param1:Event):void
  660.          {
  661.             complete = true;
  662.             if(unloaded)
  663.             {
  664.                MochiAd.unload(clip);
  665.             }
  666.          };
  667.          clip.loaderInfo.addEventListener(Event.COMPLETE,f);
  668.          if(clip.root is MovieClip)
  669.          {
  670.             r = clip.root as MovieClip;
  671.             if(r.framesLoaded >= r.totalFrames)
  672.             {
  673.                complete = true;
  674.             }
  675.          }
  676.          mc.unloadAd = function():void
  677.          {
  678.             unloaded = true;
  679.             if(complete)
  680.             {
  681.                MochiAd.unload(clip);
  682.             }
  683.          };
  684.          mc.adjustProgress = function(param1:Number):void
  685.          {
  686.             var _loc2_:Object = null;
  687.             _loc2_ = mc._mochiad_wait;
  688.             _loc2_.server_control = true;
  689.             _loc2_.started = getTimer();
  690.             _loc2_.ad_msec = param1;
  691.          };
  692.          chk["onEnterFrame"] = function():void
  693.          {
  694.             var _loc1_:Object = null;
  695.             var _loc2_:Object = null;
  696.             var _loc3_:Number = NaN;
  697.             var _loc4_:Boolean = false;
  698.             var _loc5_:Number = NaN;
  699.             var _loc6_:Number = NaN;
  700.             var _loc7_:Number = NaN;
  701.             var _loc8_:Number = NaN;
  702.             var _loc9_:Object = null;
  703.             var _loc10_:Number = NaN;
  704.             var _loc11_:Number = NaN;
  705.             if(!this.parent.parent)
  706.             {
  707.                delete this["onEnterFrame"];
  708.                return;
  709.             }
  710.             _loc1_ = this.parent.parent.root;
  711.             _loc2_ = this.parent._mochiad_ctr;
  712.             _loc3_ = getTimer() - this.started;
  713.             _loc4_ = false;
  714.             _loc5_ = _loc1_.loaderInfo.bytesTotal;
  715.             _loc6_ = _loc1_.loaderInfo.bytesLoaded;
  716.             _loc7_ = 100 * _loc6_ / _loc5_;
  717.             _loc8_ = 100 * _loc3_ / chk.ad_msec;
  718.             _loc9_ = this._mochiad_bar._inside;
  719.             _loc10_ = Math.min(100,Math.min(Number(_loc7_) || Number(0),_loc8_));
  720.             _loc10_ = Math.max(this.last_pcnt,_loc10_);
  721.             this.last_pcnt = _loc10_;
  722.             _loc9_.scaleX = _loc10_ * 0.01;
  723.             if(!chk.showing)
  724.             {
  725.                if((_loc11_ = _loc2_.loaderInfo.bytesTotal) > 0 || "number" == "undefined")
  726.                {
  727.                   chk.showing = true;
  728.                   chk.started = getTimer();
  729.                }
  730.                else if(_loc3_ > chk.ad_timeout)
  731.                {
  732.                   _loc4_ = true;
  733.                }
  734.             }
  735.             if(_loc3_ > chk.ad_msec || this.parent._mochiad_ctr_failed)
  736.             {
  737.                _loc4_ = true;
  738.             }
  739.             if(complete && _loc4_)
  740.             {
  741.                if(this.server_control)
  742.                {
  743.                   delete this.onEnterFrame;
  744.                }
  745.                else
  746.                {
  747.                   this.fadeout_start = getTimer();
  748.                   this.onEnterFrame = chk.fadeFunction;
  749.                }
  750.             }
  751.          };
  752.          doOnEnterFrame(chk);
  753.       }
  754.       
  755.       public static function showPreloaderAd(param1:Object) : void
  756.       {
  757.          MochiAd.showPreGameAd(param1);
  758.       }
  759.       
  760.       public static function fetchHighScores(param1:Object, param2:Object, param3:Object = null) : Boolean
  761.       {
  762.          var _loc4_:MovieClip = null;
  763.          if(!(_loc4_ = MochiAd._loadCommunicator({
  764.             "clip":param1.clip,
  765.             "id":param1.id
  766.          })))
  767.          {
  768.             return false;
  769.          }
  770.          _loc4_.doSend(["fetchHighScores",param1],param2,param3);
  771.          return true;
  772.       }
  773.       
  774.       public static function doOnEnterFrame(param1:MovieClip) : void
  775.       {
  776.          var f:Function = null;
  777.          var mc:MovieClip = param1;
  778.          f = function(param1:Object):void
  779.          {
  780.             if("onEnterFrame" in mc && mc.onEnterFrame)
  781.             {
  782.                mc.onEnterFrame();
  783.             }
  784.             else
  785.             {
  786.                mc.removeEventListener(Event.ENTER_FRAME,f);
  787.             }
  788.          };
  789.          mc.addEventListener(Event.ENTER_FRAME,f);
  790.       }
  791.    }
  792. }
  793.