home *** CD-ROM | disk | FTP | other *** search
/ PC/CD Gamer UK 231 / PCG231DB1011.ISO / pc / Interface / main.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2008-04-09  |  7.0 KB  |  258 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. }
  88. function debugPrint(args)
  89. {
  90.    fscommand("DebugPrint",args);
  91. }
  92. function TestPythonFunction(myArg)
  93. {
  94.    _root.backdrop_image._visible = false;
  95.    return "yes";
  96. }
  97. function MakeProductPage(gameTitle, infoText, images, bData)
  98. {
  99.    game_title = gameTitle;
  100.    infoDisplay.info_text = infoText;
  101.    makeProductButtons(bData);
  102.    imgsList = images.split("|");
  103.    screenDisplay.loadImages(imgsList);
  104. }
  105. function setIntroImages(imgs)
  106. {
  107.    screenDisplay.loadImages(imgs.split("|"));
  108. }
  109. function introTextRecieved(welcomeText, introText, issueText)
  110. {
  111.    issueNumber = issueText;
  112.    game_title = welcomeText;
  113.    infoDisplay.info_text = introText;
  114. }
  115. function makeProductButtons(args)
  116. {
  117.    buttonList = args.split("%%");
  118.    var _loc2_ = Array("but1","but2","but3","but4","but5","but6");
  119.    bn = 0;
  120.    while(bn < _loc2_.length)
  121.    {
  122.       if(bn < buttonList.length - 1)
  123.       {
  124.          comTxt = buttonList[bn];
  125.          _root[_loc2_[bn]].buttonText = comTxt;
  126.          _root[_loc2_[bn]]._visible = true;
  127.       }
  128.       else
  129.       {
  130.          _root[_loc2_[bn]]._visible = false;
  131.       }
  132.       bn++;
  133.    }
  134. }
  135. function createMenuSystem(indexData)
  136. {
  137.    debugPrint("CreateMenuSystem Called HERE");
  138.    idx = String(indexData);
  139.    sections = idx.split("---");
  140.    sections.shift();
  141.    debugPrint(sections.length);
  142.    fscommand("DebugPrint",String(sections));
  143.    debugWindow = sections.length;
  144.    var _loc4_ = 0;
  145.    var _loc3_ = 100;
  146.    pHeight = item_button._height;
  147.    sec = 0;
  148.    while(sec < sections.length)
  149.    {
  150.       pItems = sections[sec].split("-");
  151.       sectionDetails = pItems[0].split("@");
  152.       duplicateMovieClip(sectionButton,"section__" + sec,16384 + this.getNextHighestDepth());
  153.       secMc = _root["section__" + sec];
  154.       cSection = SectionObject(sectionDetails[0],sectionDetails[1],secMc);
  155.       sectionsIndex.push(cSection);
  156.       secMc._x = _loc4_;
  157.       secMc._y = 70;
  158.       secMc.sectionObject = cSection;
  159.       currentSection = cSection;
  160.       secMc.section_title = currentSection.sectionName;
  161.       secMc.setWidth = function(wd)
  162.       {
  163.          this.butty.left_cap._x = 0;
  164.          this.butty.backer._width = wd;
  165.          this.butty.right_cap._x = this.butty.backer._x + this.butty.backer._width + this.butty.right_cap._width;
  166.          this.secTitle._x = 8;
  167.          this.secTitle._width = wd + 20;
  168.       };
  169.       secMc.setWidth(secMc.section_title.length * 7);
  170.       secMc.onRelease = function()
  171.       {
  172.          _root.hideSectionsOtherThan(this.sectionObject);
  173.       };
  174.       _loc3_ = 100;
  175.       i = 1;
  176.       while(i < pItems.length)
  177.       {
  178.          iName = String(sec + "__" + i);
  179.          itemDetails = pItems[i].split("@");
  180.          duplicateMovieClip(item_button,iName,16384 + this.getNextHighestDepth());
  181.          mc = _root[iName];
  182.          itemOb = itemObject(itemDetails[0],itemDetails[1],mc);
  183.          currentSection.pItems.push(itemOb);
  184.          mc._x = 0;
  185.          mc._y = _loc3_;
  186.          mc.sectionPath = currentSection.sectionPath;
  187.          mc.itemData = itemOb;
  188.          mc.onRelease = function()
  189.          {
  190.             _root.getProductPage(this);
  191.          };
  192.          _loc3_ += pHeight;
  193.          i++;
  194.       }
  195.       _loc4_ += secMc._width;
  196.       item = 0;
  197.       while(item < cSection.pItems.length)
  198.       {
  199.          cSection.pItems[item].itemMC._visible = false;
  200.          item++;
  201.       }
  202.       sec++;
  203.    }
  204.    secMc._visible = true;
  205.    hideSectionsOtherThan(sectionsIndex[0]);
  206.    sectionsIndex[0].secMC.gotoAndStop(20);
  207.    sectionsIndex[0].secMC.clicked = true;
  208.    return "Flash Recieved: " + indexData;
  209. }
  210. function doCommand(command, someParams)
  211. {
  212.    fscommand(command,someParams);
  213. }
  214. function getProductPage(itemMC)
  215. {
  216.    secP = itemMC.sectionPath;
  217.    iP = itemMC.itemData.itemPath;
  218.    gotoAndStop("product");
  219.    fscommand("GetProductPageDetails",secP + "|" + iP);
  220. }
  221. function trimString(par_String)
  222. {
  223.    var _loc2_ = "";
  224.    c = 0;
  225.    while(c < par_String.length - 1)
  226.    {
  227.       if(par_String.charAt(c) != " " && par_String.charAt(c) != "\n")
  228.       {
  229.          _loc2_ += par_String.charAt(c);
  230.       }
  231.       c++;
  232.    }
  233.    return _loc2_;
  234. }
  235. function rTrim(string)
  236. {
  237.    var _loc2_ = "";
  238.    ch = string.length;
  239.    while(ch > 0)
  240.    {
  241.       if(!(string[ch] == " " || string[ch] == "\n"))
  242.       {
  243.          _loc2_ += string[ch];
  244.       }
  245.       ch--;
  246.    }
  247.    return _loc2_;
  248. }
  249. stop();
  250. flash.external.ExternalInterface.addCallback("TestPythonFunction",null,TestPythonFunction);
  251. flash.external.ExternalInterface.addCallback("MakeProductPage",null,MakeProductPage);
  252. flash.external.ExternalInterface.addCallback("SetIntroImages",null,setIntroImages);
  253. flash.external.ExternalInterface.addCallback("IntroTextRecieved",null,introTextRecieved);
  254. flash.external.ExternalInterface.addCallback("CreateMenuSystem",null,createMenuSystem);
  255. var sectionsIndex = new Array();
  256. Stage.scaleMode = "showall";
  257. __init__();
  258.