home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2012 February / maximum-cd-2012-02.iso / Interface / main.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2009-03-18  |  9.8 KB  |  363 lines

  1. function __init__()
  2. {
  3.    var _loc3_ = 1016;
  4.    var _loc4_ = 638;
  5.    var _loc2_ = new Object();
  6.    _loc2_.onLoadComplete = function(target_mc)
  7.    {
  8.       target_mc.forceSmoothing = true;
  9.    };
  10.    _loc2_.onLoadInit = function(target_mc)
  11.    {
  12.    };
  13.    mcl = new MovieClipLoader();
  14.    mcl.loadClip("./Interface/mainbackdrop.png",backdrop_image);
  15.    var _loc1_ = new LoadVars();
  16.    _loc1_.onData = function(dat)
  17.    {
  18.       if(dat)
  19.       {
  20.          createMenuSystem(dat);
  21.       }
  22.    };
  23.    _loc1_.load("./Interface/menu_items.txt");
  24.    sectionButton._visible = false;
  25.    item_button._visible = false;
  26.    doCommand("GETINTROTEXT","True");
  27. }
  28. function SectionObject(pName, pPath, mc)
  29. {
  30.    secObj = new Object();
  31.    secObj.sectionPath = trimString(pPath);
  32.    secObj.sectionName = pName;
  33.    secObj.pItems = [];
  34.    secObj.secMC = mc;
  35.    return secObj;
  36. }
  37. function itemObject(pName, pPath, mc)
  38. {
  39.    itemObj = new Object();
  40.    itemObj.itemPath = trimString(pPath);
  41.    itemObj.itemName = pName;
  42.    itemObj.itemMC = mc;
  43.    itemObj.itemMC.titleName = itemObj.itemName;
  44.    return itemObj;
  45. }
  46. function hideSectionsOtherThan(secObj)
  47. {
  48.    s = 0;
  49.    while(s < _root.sectionsIndex.length)
  50.    {
  51.       if(_root.sectionsIndex[s].secMC.clicked == true)
  52.       {
  53.          _root.sectionsIndex[s].secMC.clicked = false;
  54.          _root.sectionsIndex[s].secMC.gotoAndPlay(21);
  55.       }
  56.       it = 0;
  57.       while(it < _root.sectionsIndex[s].pItems.length)
  58.       {
  59.          _root.sectionsIndex[s].pItems[it].itemMC._visible = false;
  60.          it++;
  61.       }
  62.       s++;
  63.    }
  64.    it = 0;
  65.    while(it < secObj.pItems.length)
  66.    {
  67.       secObj.pItems[it].itemMC._visible = true;
  68.       it++;
  69.    }
  70.    secObj.secMC.clicked = true;
  71.    getProductPage(secObj.pItems[0].itemMC);
  72.    secObj.pItems[0].itemMC.gotoAndPlay(2);
  73. }
  74. function homeButton()
  75. {
  76.    s = 0;
  77.    while(s < _root.sectionsIndex.length)
  78.    {
  79.       if(_root.sectionsIndex[s].secMC.clicked == true)
  80.       {
  81.          _root.sectionsIndex[s].secMC.clicked = false;
  82.          _root.sectionsIndex[s].secMC.gotoAndPlay(21);
  83.       }
  84.       it = 0;
  85.       while(it < _root.sectionsIndex[s].pItems.length)
  86.       {
  87.          _root.sectionsIndex[s].pItems[it].itemMC._visible = false;
  88.          it++;
  89.       }
  90.       s++;
  91.    }
  92.    gotoAndStop(2);
  93. }
  94. function debugPrint(args)
  95. {
  96.    fscommand("DebugPrint",args);
  97. }
  98. function TestPythonFunction(myArg)
  99. {
  100.    _root.backdrop_image._visible = false;
  101.    return "yes";
  102. }
  103. function MakeProductPage(gameTitle, infoText, images, bData)
  104. {
  105.    game_title = gameTitle;
  106.    infoDisplay.info_text = infoText;
  107.    makeProductButtons(bData);
  108.    imgsList = images.split("|");
  109.    screenDisplay.loadImages(imgsList);
  110. }
  111. function setIntroImages(imgs)
  112. {
  113.    screenDisplay.loadImages(imgs.split("|"));
  114. }
  115. function introTextRecieved(welcomeText, introText, issueText)
  116. {
  117.    issueNumber = issueText;
  118.    game_title = welcomeText;
  119.    infoDisplay.info_text = introText;
  120. }
  121. function makeProductButtons(args)
  122. {
  123.    buttonList = args.split("%%");
  124.    var _loc2_ = Array("but1","but2","but3","but4","but5","but6");
  125.    bn = 0;
  126.    while(bn < _loc2_.length)
  127.    {
  128.       if(bn < buttonList.length - 1)
  129.       {
  130.          comTxt = buttonList[bn];
  131.          _root[_loc2_[bn]].buttonText = comTxt;
  132.          _root[_loc2_[bn]]._visible = true;
  133.       }
  134.       else
  135.       {
  136.          _root[_loc2_[bn]]._visible = false;
  137.       }
  138.       bn++;
  139.    }
  140. }
  141. function createMenuSystem(indexData)
  142. {
  143.    debugPrint("CreateMenuSystem Called HERE");
  144.    duplicateMovieClip(sectionButton,"section__home",16384 + this.getNextHighestDepth());
  145.    secMc = _root.section__home;
  146.    var _loc4_ = 0;
  147.    secMc._x = _loc4_;
  148.    secMc._y = 70;
  149.    secMc.section_title = "Home";
  150.    secMc.setWidth = function(wd)
  151.    {
  152.       this.butty.left_cap._x = 0;
  153.       this.butty.backer._width = wd;
  154.       this.butty.right_cap._x = this.butty.backer._x + this.butty.backer._width + this.butty.right_cap._width;
  155.       this.secTitle._x = 3;
  156.       this.secTitle._width = wd + 20;
  157.    };
  158.    secMc.setWidth(secMc.section_title.length * 7);
  159.    secMc.onRelease = function()
  160.    {
  161.       _root.homeButton();
  162.       doCommand("GETINTROTEXT","True");
  163.    };
  164.    _loc4_ += secMc._width;
  165.    idx = String(indexData);
  166.    sections = idx.split("---");
  167.    sections.shift();
  168.    debugPrint(sections.length);
  169.    fscommand("DebugPrint",String(sections));
  170.    debugWindow = sections.length;
  171.    var _loc3_ = 100;
  172.    pHeight = item_button._height;
  173.    sec = 0;
  174.    while(sec < sections.length)
  175.    {
  176.       pItems = sections[sec].split("-|");
  177.       sectionDetails = pItems[0].split("@@");
  178.       duplicateMovieClip(sectionButton,"section__" + sec,16384 + this.getNextHighestDepth());
  179.       secMc = _root["section__" + sec];
  180.       cSection = SectionObject(sectionDetails[0],sectionDetails[1],secMc);
  181.       sectionsIndex.push(cSection);
  182.       secMc._x = _loc4_;
  183.       secMc._y = 70;
  184.       secMc.sectionObject = cSection;
  185.       currentSection = cSection;
  186.       secMc.section_title = currentSection.sectionName;
  187.       secMc.setWidth = function(wd)
  188.       {
  189.          this.butty.left_cap._x = 0;
  190.          this.butty.backer._width = wd;
  191.          this.butty.right_cap._x = this.butty.backer._x + this.butty.backer._width + this.butty.right_cap._width;
  192.          this.secTitle._x = 3;
  193.          this.secTitle._width = wd + 20;
  194.       };
  195.       secMc.setWidth(secMc.section_title.length * 7);
  196.       secMc.onRelease = function()
  197.       {
  198.          _root.hideSectionsOtherThan(this.sectionObject);
  199.       };
  200.       _loc3_ = 100;
  201.       i = 1;
  202.       while(i < pItems.length)
  203.       {
  204.          iName = String(sec + "__" + i);
  205.          itemDetails = pItems[i].split("@@");
  206.          duplicateMovieClip(item_button,iName,16384 + this.getNextHighestDepth());
  207.          mc = _root[iName];
  208.          itemOb = itemObject(itemDetails[0],itemDetails[1],mc);
  209.          currentSection.pItems.push(itemOb);
  210.          mc._x = 0;
  211.          mc._y = _loc3_;
  212.          mc.sectionPath = currentSection.sectionPath;
  213.          mc.itemData = itemOb;
  214.          mc.onRelease = function()
  215.          {
  216.             _root.getProductPage(this);
  217.          };
  218.          _loc3_ += pHeight;
  219.          i++;
  220.       }
  221.       _loc4_ += secMc._width;
  222.       item = 0;
  223.       while(item < cSection.pItems.length)
  224.       {
  225.          cSection.pItems[item].itemMC._visible = false;
  226.          item++;
  227.       }
  228.       sec++;
  229.    }
  230.    secMc._visible = true;
  231.    return "Flash Recieved: " + indexData;
  232. }
  233. function doCommand(command, someParams)
  234. {
  235.    fscommand(command,someParams);
  236. }
  237. function getProductPage(itemMC)
  238. {
  239.    trace(itemMC.itemData.itemName);
  240.    if(itemMC.itemData.itemName.charAt(0) != " ")
  241.    {
  242.       secP = itemMC.sectionPath;
  243.       iP = itemMC.itemData.itemPath;
  244.       gotoAndStop("product");
  245.       fscommand("GetProductPageDetails",secP + "|" + iP);
  246.    }
  247.    else
  248.    {
  249.       trace("Empty Item");
  250.    }
  251. }
  252. function trimString(par_String)
  253. {
  254.    var _loc2_ = "";
  255.    c = 0;
  256.    while(c < par_String.length - 1)
  257.    {
  258.       if(par_String.charAt(c) != " " && par_String.charAt(c) != "\n")
  259.       {
  260.          _loc2_ += par_String.charAt(c);
  261.       }
  262.       c++;
  263.    }
  264.    return _loc2_;
  265. }
  266. function rTrim(string)
  267. {
  268.    var _loc2_ = "";
  269.    ch = string.length;
  270.    while(ch > 0)
  271.    {
  272.       if(!(string[ch] == " " || string[ch] == "\n"))
  273.       {
  274.          _loc2_ += string[ch];
  275.       }
  276.       ch--;
  277.    }
  278.    return _loc2_;
  279. }
  280. function loadPreRoll(preRollLocation)
  281. {
  282.    skipper._visible = false;
  283.    if(preRollLocation == "none")
  284.    {
  285.       preroll._visible = false;
  286.       vid_bg._visible = false;
  287.       skipper._visible = false;
  288.       __init__();
  289.    }
  290.    else
  291.    {
  292.       preroll.load("Interface/pre_roll.flv");
  293.       preroll.play();
  294.       skipperInterval = setInterval(showSkipButton,3000);
  295.    }
  296. }
  297. function showSkipButton()
  298. {
  299.    clearInterval(skipperInterval);
  300.    skipper._visible = true;
  301. }
  302. function skipPreRoll()
  303. {
  304.    clearInterval(skipperInterval);
  305.    preroll.pause();
  306.    skipper._visible = false;
  307.    preroll._visible = false;
  308.    vid_bg._visible = false;
  309.    __init__();
  310. }
  311. stop();
  312. flash.external.ExternalInterface.addCallback("TestPythonFunction",null,TestPythonFunction);
  313. flash.external.ExternalInterface.addCallback("MakeProductPage",null,MakeProductPage);
  314. flash.external.ExternalInterface.addCallback("SetIntroImages",null,setIntroImages);
  315. flash.external.ExternalInterface.addCallback("IntroTextRecieved",null,introTextRecieved);
  316. flash.external.ExternalInterface.addCallback("CreateMenuSystem",null,createMenuSystem);
  317. MovieClip(preroll.getVideoPlayer(preroll.activeVideoPlayerIndex))._video.smoothing = true;
  318. var listenerObject = new Object();
  319. listenerObject.metadataReceived = function(eventObject)
  320. {
  321.    var _loc8_ = 1016;
  322.    var _loc2_ = 618;
  323.    var _loc5_ = preroll.metadata.width;
  324.    var _loc6_ = preroll.metadata.height;
  325.    trace("in ratio = " + _loc5_ / _loc6_);
  326.    var _loc9_ = undefined;
  327.    var _loc3_ = undefined;
  328.    var _loc1_ = undefined;
  329.    var _loc4_ = 0;
  330.    var _loc7_ = 0;
  331.    _loc9_ = _loc6_ / _loc5_;
  332.    _loc3_ = _loc8_;
  333.    _loc1_ = _loc3_ * _loc9_;
  334.    if(_loc1_ > _loc2_)
  335.    {
  336.       reduce = _loc2_ / _loc1_;
  337.       _loc1_ *= reduce;
  338.       _loc3_ *= reduce;
  339.    }
  340.    trace("out height=" + _loc1_ + "    frame height=" + _loc2_);
  341.    _loc4_ = _loc2_ - _loc1_;
  342.    _loc7_ = (_loc8_ - _loc3_) / 2;
  343.    trace(_loc4_);
  344.    preroll._width = _loc3_;
  345.    preroll._height = _loc1_;
  346.    preroll._y = _loc4_;
  347.    preroll._x = _loc7_;
  348. };
  349. listenerObject.complete = function(evt)
  350. {
  351.    preroll._visible = false;
  352.    vid_bg._visible = false;
  353.    skipper._visible = false;
  354.    _root.__init__();
  355. };
  356. preroll.addEventListener("metadataReceived",listenerObject);
  357. preroll.addEventListener("complete",listenerObject);
  358. var skipperInterval;
  359. flash.external.ExternalInterface.addCallback("LoadPreRoll",null,loadPreRoll);
  360. var sectionsIndex = new Array();
  361. Stage.scaleMode = "showall";
  362. fscommand("checkPreRoll","0");
  363.