home *** CD-ROM | disk | FTP | other *** search
/ PC/CD Gamer UK 231 / PCG231DB1011.ISO / pc / main.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2008-09-01  |  10.3 KB  |  379 lines

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