home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / beach_difference.swf / scripts / DefineSprite_600 / frame_1 / DoAction.as
Encoding:
Text File  |  2008-09-23  |  10.2 KB  |  332 lines

  1. function brain()
  2. {
  3.    create_assets(myself,_global.obj_iads.type);
  4.    switch(_global.obj_iads.type)
  5.    {
  6.       case "FULL":
  7.          mcLoader.loadClip(_global.obj_iads.url,trgt_main);
  8.          break;
  9.       case "EMBED":
  10.          mcLoader.loadClip(_global.obj_iads.url,trgt_main.trgt_ads);
  11.          if(_global.obj_iads.link ne undefined)
  12.          {
  13.             trgt_main.onRelease = function()
  14.             {
  15.                getURL(_global.obj_iads.link,"_blank");
  16.             };
  17.          }
  18.          break;
  19.       case "NOOP":
  20.          clearInterval(int1);
  21.          _root.play();
  22.    }
  23. }
  24. function get_iads()
  25. {
  26.    lv_iads = new XML();
  27.    lv_result = new XML();
  28.    lv_result.ignoreWhite = true;
  29.    lv_result.onLoad = function(success)
  30.    {
  31.       if(success)
  32.       {
  33.          parse_iads(lv_result);
  34.       }
  35.       else
  36.       {
  37.          _root.play();
  38.       }
  39.    };
  40.    lv_iads.sendAndLoad(adurl,lv_result,"POST");
  41. }
  42. function parse_iads(lv_result)
  43. {
  44.    _global.obj_iads = new Array();
  45.    var _loc2_ = 0;
  46.    while(_loc2_ < lv_result.firstChild.childNodes.length)
  47.    {
  48.       if(lv_result.firstChild.childNodes[_loc2_].firstChild.nodeValue != null)
  49.       {
  50.          obj_iads[lv_result.firstChild.childNodes[_loc2_].nodeName] = lv_result.firstChild.childNodes[_loc2_].firstChild.nodeValue;
  51.       }
  52.       else if(lv_result.firstChild.childNodes[_loc2_].firstChild.firstChild.nodeValue != null)
  53.       {
  54.          var _loc5_ = new Object();
  55.          var _loc4_ = 0;
  56.          while(_loc4_ < lv_result.firstChild.childNodes[_loc2_].childNodes.length)
  57.          {
  58.             _loc5_[lv_result.firstChild.childNodes[_loc2_].childNodes[_loc4_].nodeName] = lv_result.firstChild.childNodes[_loc2_].childNodes[_loc4_].firstChild.nodeValue;
  59.             _loc4_ = _loc4_ + 1;
  60.          }
  61.          obj_iads[lv_result.firstChild.childNodes[_loc2_].nodeName] = _loc5_;
  62.       }
  63.       _loc2_ = _loc2_ + 1;
  64.    }
  65.    show_time = int(_global.obj_iads.t);
  66.    check_type();
  67. }
  68. function time_delay()
  69. {
  70.    tim = 0;
  71.    int1 = setInterval(timespam,1000);
  72. }
  73. function timespam()
  74. {
  75.    tim++;
  76.    trace(tim);
  77.    if(tim == show_time)
  78.    {
  79.       clearInterval(int1);
  80.       _root.play();
  81.    }
  82. }
  83. function create_assets(mc, _type)
  84. {
  85.    mc.createEmptyMovieClip("whitebg",0);
  86.    whitebg.beginFill(16777215);
  87.    whitebg.moveTo(0,0);
  88.    whitebg.lineTo(0,0);
  89.    whitebg.lineTo(Stage.width,0);
  90.    whitebg.lineTo(Stage.width,Stage.height + 20);
  91.    whitebg.lineTo(0,Stage.height + 20);
  92.    whitebg.endFill();
  93.    mc.createEmptyMovieClip("trgt_main",4);
  94.    mcLoader = new MovieClipLoader();
  95.    mcLoader.addListener(mc);
  96.    if(_type != "FULL")
  97.    {
  98.       mc.createEmptyMovieClip("square_mc",5);
  99.       var _loc4_ = trgt_main.createEmptyMovieClip("trgt_ads",getNextHighestDepth());
  100.       var _loc3_ = new TextFormat();
  101.       _loc3_.align = "center";
  102.       _loc3_.font = "Verdana";
  103.       _loc3_.size = 10;
  104.       var _loc2_ = new TextFormat();
  105.       _loc2_.align = "right";
  106.       _loc2_.font = "Verdana";
  107.       _loc2_.size = 10;
  108.       _loc2_.underline = true;
  109.       mc.createTextField("h_txt",mc.getNextHighestDepth(),0,0,100,22);
  110.       mc.createTextField("b_txt",mc.getNextHighestDepth(),0,0,100,22);
  111.       mc.createTextField("m_txt",mc.getNextHighestDepth(),0,0,120,22);
  112.       b_txt.autoSize = true;
  113.       m_txt.autoSize = true;
  114.       b_txt.selectable = false;
  115.       h_txt.selectable = false;
  116.       m_txt.selectable = false;
  117.       m_txt.html = true;
  118.       b_txt.multiline = true;
  119.       b_txt.setNewTextFormat(_loc3_);
  120.       h_txt.autoSize = true;
  121.       h_txt.setNewTextFormat(_loc3_);
  122.       m_txt.setNewTextFormat(_loc2_);
  123.       h_txt.text = "";
  124.       mc.createEmptyMovieClip("progressBar",500);
  125.    }
  126. }
  127. function onLoadInit(mc)
  128. {
  129.    ad_width = int(_global.obj_iads.x);
  130.    ad_height = int(_global.obj_iads.y);
  131.    h_txt.text = "Advertisement";
  132.    loadMessages();
  133.    progressBar.tim = show_time;
  134.    progressBar.width = _global.obj_iads.x;
  135.    progressBar.height = 15;
  136.    progressBar.start = function()
  137.    {
  138.       game_fps = getFps();
  139.       maxw = this.width - 2;
  140.       this.ad = maxw / (this.tim + 1);
  141.       this.ad /= game_fps;
  142.    };
  143.    progressBar.onEnterFrame = function()
  144.    {
  145.       if(this.bar._width < this.width - 2)
  146.       {
  147.          this.bar._width += this.ad;
  148.       }
  149.       else
  150.       {
  151.          this.bar._width = this.width;
  152.       }
  153.    };
  154.    progressBar._x = 100;
  155.    progressBar._y = 100;
  156.    bar_mc = progressBar.createEmptyMovieClip("bar",1);
  157.    box_mc = progressBar.createEmptyMovieClip("box",2);
  158.    bar_mc.beginFill(26112);
  159.    bar_mc.moveTo(0,0);
  160.    bar_mc.lineTo(1,0);
  161.    bar_mc.lineTo(1,progressBar.height - 2);
  162.    bar_mc.lineTo(0,progressBar.height - 2);
  163.    bar_mc.lineTo(0,0);
  164.    bar_mc.endFill();
  165.    bar_mc._x = 1.5;
  166.    bar_mc._y = 1.5;
  167.    box_mc.lineStyle(1,3355443,100,true,"none","round","miter",1);
  168.    box_mc.lineTo(progressBar.width,0);
  169.    box_mc.lineTo(progressBar.width,progressBar.height);
  170.    box_mc.lineTo(0,progressBar.height);
  171.    box_mc.lineTo(0,0);
  172.    box_mc._x = 0;
  173.    box_mc._y = 0;
  174.    progressBar.start();
  175.    b_txt.text = "Note\rClicking on the above Ad won\'t interrupt your game.\rAd link opens in a new window.";
  176.    myself._y = b_txt._y - 10;
  177.    x = Stage.width / 2 - ad_width / 2;
  178.    y = Stage.height / 2 - ad_height / 2;
  179.    mc._x = x;
  180.    mc._y = y;
  181.    h_txt._x = x + ad_width / 2 - h_txt._width / 2;
  182.    h_txt._y = y - 20;
  183.    progressBar._x = x + ad_width / 2 - progressBar._width / 2;
  184.    progressBar._y = y + 5 + ad_height;
  185.    myself.invizi_logo.swapDepths(myself.getNextHighestDepth());
  186.    myself.invizi_logo._alpha = 100;
  187.    myself.invizi_logo._x = int(progressBar._x);
  188.    myself.invizi_logo._y = int(progressBar._y + progressBar._height) + 5;
  189.    m_txt._x = int(progressBar._x + progressBar._width) - m_txt._width;
  190.    m_txt._y = int(progressBar._y + progressBar._height) + 3;
  191.    myself.invizi_logo.onRelease = function()
  192.    {
  193.       getUrl("http://www.inviziads.com/index.html?utm_source=4_1&utm_medium=logo&utm_content=default&utm_campaign=invizi", "_blank");
  194.    };
  195.    b_txt._x = x + ad_width / 2 - b_txt._width / 2;
  196.    b_txt._y = progressBar._y + 38;
  197.    square_mc.beginFill(16711680);
  198.    square_mc.moveTo(0,0);
  199.    square_mc.lineTo(ad_width,0);
  200.    square_mc.lineTo(ad_width,ad_height);
  201.    square_mc.lineTo(0,ad_height);
  202.    square_mc.lineTo(0,0);
  203.    square_mc.endFill();
  204.    square_mc._x = x;
  205.    square_mc._y = y;
  206.    trgt_main.setMask(square_mc);
  207. }
  208. function loadMessages()
  209. {
  210.    lv_messages = new XML();
  211.    lv_messages.ignoreWhite = true;
  212.    lv_messages.onLoad = function(success)
  213.    {
  214.       if(success)
  215.       {
  216.          totalNodes = lv_messages.firstChild.childNodes.length;
  217.          ran = Math.floor(Math.random() * totalNodes);
  218.          if(lv_messages.firstChild.childNodes[ran].firstChild == undefined)
  219.          {
  220.             m_txt.htmlText = "<font color=\'#0066CC\'><a href=\'http://www.inviziads.com/adv-starter-pack.html\' target=\'_blank\'>Advertisers, try us out for US$250</a></font>";
  221.          }
  222.          else
  223.          {
  224.             m_txt.htmlText = "<font color=\'#0066CC\'><a href=\'" + lv_messages.firstChild.childNodes[ran].attributes.link + "\' target=\'_blank\'>" + lv_messages.firstChild.childNodes[ran].firstChild + "</a></font>";
  225.          }
  226.          m_txt._x = int(progressBar._x + progressBar._width) - m_txt._width;
  227.          m_txt._y = int(progressBar._y + progressBar._height) + 2;
  228.       }
  229.       else
  230.       {
  231.          m_txt.htmlText = "<font color=\'#0066CC\'><a href=\'http://inviziads.com\' target=\'_blank\'>Advertisers, try us out for US$250</a></font>";
  232.          m_txt._x = int(progressBar._x + progressBar._width) - m_txt._width;
  233.          m_txt._y = int(progressBar._y + progressBar._height) + 2;
  234.       }
  235.    };
  236.    lv_messages.load(messageURL);
  237. }
  238. function pushdata()
  239. {
  240.    holder.obj_iads = _global.obj_iads;
  241. }
  242. function startdatapush(mc)
  243. {
  244.    var _loc2_ = undefined;
  245.    _loc2_ = setInterval(this,"pushdata",10);
  246. }
  247. function check_type()
  248. {
  249.    if(_global.obj_iads.type eq "UPDATE")
  250.    {
  251.       myself.createEmptyMovieClip("holder",100);
  252.       var _loc3_ = _global.obj_iads.url;
  253.       obj_iads = _global.obj_iads;
  254.       var _loc2_ = new MovieClipLoader();
  255.       _loc2_.loadClip(_global.obj_iads.url,holder);
  256.    }
  257.    else
  258.    {
  259.       brain();
  260.       time_delay();
  261.    }
  262. }
  263. function parse_xml(mydata)
  264. {
  265.    var _loc4_ = new Array();
  266.    var _loc1_ = 0;
  267.    while(_loc1_ < mydata.firstChild.childNodes.length)
  268.    {
  269.       if(mydata.firstChild.childNodes[_loc1_].firstChild.nodeValue != null)
  270.       {
  271.          _loc4_[mydata.firstChild.childNodes[_loc1_].nodeName] = mydata.firstChild.childNodes[_loc1_].firstChild.nodeValue;
  272.       }
  273.       else if(mydata.firstChild.childNodes[_loc1_].firstChild.firstChild.nodeValue != null)
  274.       {
  275.          var _loc5_ = new Object();
  276.          var _loc2_ = 0;
  277.          while(_loc2_ < lv_result.firstChild.childNodes[_loc1_].childNodes.length)
  278.          {
  279.             _loc4_[lv_result.firstChild.childNodes[_loc1_].childNodes[_loc2_].nodeName] = mydata.firstChild.childNodes[_loc1_].childNodes[_loc2_].firstChild.nodeValue;
  280.             _loc2_ = _loc2_ + 1;
  281.          }
  282.          _loc4_[lv_result.firstChild.childNodes[_loc1_].nodeName] = _loc5_;
  283.       }
  284.       _loc1_ = _loc1_ + 1;
  285.    }
  286.    return _loc4_;
  287. }
  288. System.security.allowDomain("*");
  289. System.security.allowInsecureDomain("*");
  290. var time = 0;
  291. var tim = 0;
  292. var show_time = 0;
  293. var tempo = 0;
  294. var int1;
  295. getFps = function()
  296. {
  297.    if(signal == true)
  298.    {
  299.       time = getTimer();
  300.    }
  301.    else
  302.    {
  303.       tempo = int(1000 / (getTimer() - time));
  304.    }
  305.    signal = !signal;
  306.    return tempo;
  307. };
  308. this.onEnterFrame = function()
  309. {
  310.    game_fps = getFps();
  311.    if(game_fps != 0 && game_fps != undefined)
  312.    {
  313.       this.onEnterFrame = null;
  314.    }
  315. };
  316. myself = this;
  317. signal = true;
  318. var purl = flash.external.ExternalInterface.call("document.URL.toString");
  319. var hurl = escape(_root._url);
  320. var adurl = "http://s1.inviziads.com/lookup.html?";
  321. adurl += "g=1127";
  322. adurl += "&h=g2w";
  323. adurl += "&type=pre";
  324. adurl += "&v=4_3";
  325. adurl += "&purl=" + escape(purl);
  326. adurl += "&hurl=" + hurl;
  327. var my_date = new Date();
  328. adurl += "&ts=" + my_date.getSeconds();
  329. var messageURL = "http://s1.inviziads.com/template/invizi_messages.xml";
  330. get_iads();
  331. _root.stop();
  332.