home *** CD-ROM | disk | FTP | other *** search
/ Computer Arts 147 / Arts147.mdf / pc / CA.swf / scripts / frame_5 / DoAction.as < prev   
Encoding:
Text File  |  2008-01-01  |  8.2 KB  |  366 lines

  1. function setActiveItem(mc)
  2. {
  3.    activeSection = mc;
  4.    sectionTitle = mc.secName;
  5. }
  6. function unClickActiveItems()
  7. {
  8.    if(activeSection)
  9.    {
  10.       i = 0;
  11.       while(i < activeSection.pItems.length)
  12.       {
  13.          activeSection.pItems[i].gotoAndStop(1);
  14.          i++;
  15.       }
  16.    }
  17. }
  18. function itemObject(pName, pPath)
  19. {
  20.    iObj = new Object();
  21.    iObj.pName = pName.slice(0,-1);
  22.    iObj.pPath = pPath.slice(0,-2);
  23.    return iObj;
  24. }
  25. function sectionObject(pName, pPath)
  26. {
  27.    sObj = new Object();
  28.    sObj.pName = pName.slice(0,-1);
  29.    sObj.pPath = pPath.indexOf("\n") == -1 ? pPath : pPath.slice(0,-2);
  30.    sObj.pItems = new Array();
  31.    return sObj;
  32. }
  33. function makeMenus(lst)
  34. {
  35.    tmp = lst.split("---");
  36.    tmp.shift();
  37.    ln = 0;
  38.    while(ln < tmp.length)
  39.    {
  40.       it = tmp[ln].split("-");
  41.       section = it[0].split("@");
  42.       menuObject.push(sectionObject(section[0],section[1]));
  43.       currentObj = menuObject[ln];
  44.       sub = 1;
  45.       while(sub < it.length)
  46.       {
  47.          item = it[sub].split("@");
  48.          obj = itemObject(item[0],item[1]);
  49.          currentObj.pItems.push(obj);
  50.          sub++;
  51.       }
  52.       ln++;
  53.    }
  54.    xPos = 323;
  55.    itemCount = 0;
  56.    sec = 0;
  57.    while(sec < menuObject.length)
  58.    {
  59.       ixPos = 350;
  60.       iyPos = 210;
  61.       pSec = menuObject[sec];
  62.       duplicateMovieClip(secObj,"secObj" + sec,16384 + this.getNextHighestDepth());
  63.       mc = _root["secObj" + sec];
  64.       menuMcs.push(mc);
  65.       mc.secName = pSec.pName;
  66.       mc.secPath = pSec.pPath;
  67.       mc.pItems = new Array();
  68.       itemsArray = new Array();
  69.       i = 0;
  70.       while(i < pSec.pItems.length)
  71.       {
  72.          trace(pSec.pItems[i].pName);
  73.          duplicateMovieClip(itemObj,"itemObj" + itemCount,16384 + this.getNextHighestDepth());
  74.          imc = _root["itemObj" + itemCount];
  75.          imc.iName = pSec.pItems[i].pName;
  76.          imc.pPath = pSec.pItems[i].pPath;
  77.          imc.secPath = pSec.pPath;
  78.          imc._x = ixPos;
  79.          imc._y = iyPos;
  80.          imc._visible = false;
  81.          mc.pItems.push(imc);
  82.          if(i == 2 || i == 5 || i == 8 || i == 11 || i == 14)
  83.          {
  84.             ixPos = 350;
  85.             iyPos += 12;
  86.          }
  87.          else
  88.          {
  89.             ixPos += 170;
  90.          }
  91.          itemCount += 1;
  92.          i++;
  93.       }
  94.       mc._x = xPos;
  95.       mc._y = 180;
  96.       xPos += 170;
  97.       sec++;
  98.    }
  99. }
  100. function loadPictures(path, imgList)
  101. {
  102.    imgs = Array();
  103.    i = 0;
  104.    while(i < imgList.length)
  105.    {
  106.       imgs.push(path + _global.delim + imgList[i]);
  107.       i++;
  108.    }
  109.    imgLoader.setImageList(imgs);
  110.    videoWindow._visible = false;
  111.    imgLoader._visible = true;
  112. }
  113. function setPictureNumber(num)
  114. {
  115.    imgLoader.setImageButtonClicked(num);
  116.    imgLoader.loadImage(num);
  117. }
  118. function loadVideo(resources, num)
  119. {
  120.    videoWindow._visible = true;
  121.    vPath = resolveVideoURL(myAppPath + currentVideoPath + _global.delim + resources[num]);
  122.    trace("LOADING VIDEO: " + vPath);
  123.    videoWindow.setContentPath(vPath);
  124.    imgLoader._visible = false;
  125. }
  126. function setVideoPath(path)
  127. {
  128.    currentVideoPath = path;
  129. }
  130. function setVideoResourcesList(lst)
  131. {
  132.    trace(lst);
  133.    videoResourceList = lst;
  134.    pNum = lst.length;
  135.    videoWindow.setVideoLabels(pNum);
  136. }
  137. function setMenuVisible(bool)
  138. {
  139.    if(bool)
  140.    {
  141.       mc = 0;
  142.       while(mc < menuMcs.length)
  143.       {
  144.          menuMcs[mc]._visible = true;
  145.          mc++;
  146.       }
  147.       m = 0;
  148.       while(m < activeSection.pItems.length)
  149.       {
  150.          activeSection.pItems[m]._visible = true;
  151.          m++;
  152.       }
  153.    }
  154.    else
  155.    {
  156.       mc = 0;
  157.       while(mc < menuMcs.length)
  158.       {
  159.          menuMcs[mc]._visible = false;
  160.          imc = 0;
  161.          while(imc < menuMcs[mc].pItems.length)
  162.          {
  163.             menuMcs[mc].pItems[imc]._visible = false;
  164.             imc++;
  165.          }
  166.          mc++;
  167.       }
  168.    }
  169. }
  170. function setInfoText(txt)
  171. {
  172.    if(txt != undefined)
  173.    {
  174.       mainTextBox.htmlText = txt;
  175.    }
  176. }
  177. function loadInfoText(path)
  178. {
  179.    infoLoader.load(path + _global.delim + "info.txt");
  180. }
  181. function setMainTitle(txt)
  182. {
  183.    infoTitle = txt;
  184. }
  185. function unClickMenus()
  186. {
  187.    infoTitle = "";
  188.    infoText = "";
  189.    sec = 0;
  190.    while(sec < menuObject.length)
  191.    {
  192.       _root["secObj" + sec].gotoAndStop(1);
  193.       _root["secObj" + sec].hideItems();
  194.       sec++;
  195.    }
  196. }
  197. function stopVideo()
  198. {
  199.    if(flvPlaying)
  200.    {
  201.       this.videoWindow.myVideoPlayer.pause();
  202.    }
  203. }
  204. function getFixedPath(path)
  205. {
  206.    if(_level0._url == "" || _level0._url == undefined)
  207.    {
  208.       fixedPath = path;
  209.    }
  210.    else
  211.    {
  212.       fixedPath = _level0._url + _global.delim + path;
  213.    }
  214.    return fixedPath;
  215. }
  216. function setOpenFolder(path, platformNumber)
  217. {
  218.    trace("Setting Open Folder " + path + " " + platformNumber);
  219.    pathTest = path;
  220.    plat = System.capabilities.os;
  221.    if(plat.toLowerCase().indexOf("win") != -1)
  222.    {
  223.       xPath = mdm.Application.path + path;
  224.       openFolderButton.setPath(xPath);
  225.       openFolderButton._visible = true;
  226.       rootOpenFolderPath = xPath;
  227.    }
  228.    else
  229.    {
  230.       openFolderButton._visible = false;
  231.       openFolderMacPathIndicator.pathText = path;
  232.       openFolderMacPathIndicator._visible = true;
  233.    }
  234.    imgLoader._visible = true;
  235.    videoWindow._visible = false;
  236. }
  237. function zoomVideoPlayer()
  238. {
  239.    flvPlaying = false;
  240.    if(videoZoomed)
  241.    {
  242.       setMenuVisible(true);
  243.       videoWindow.gotoAndStop(1);
  244.       setVideoItem(0);
  245.       videoWindow.myVideoPlayer.play();
  246.    }
  247.    else
  248.    {
  249.       trace("Big Video Player");
  250.       setMenuVisible(false);
  251.       cPath = videoWindow.myVideoPlayer.contentPath;
  252.       videoWindow.gotoAndStop(2);
  253.       trace(videoWindow.bigVideoPlayer._x);
  254.       setVideoItem(0);
  255.       trace(videoWindow.bigVideoPlayer.contentPath);
  256.       videoWindow.bigVideoPlayer.play();
  257.    }
  258.    videoZoomed = !videoZoomed;
  259. }
  260. function toggleVideoSelector()
  261. {
  262.    if(selectorVisible)
  263.    {
  264.       videoWindow.videoSelector._visible = false;
  265.       selectorVisible = false;
  266.    }
  267.    else
  268.    {
  269.       videoWindow.videoSelector._visible = true;
  270.       selectorVisible = true;
  271.    }
  272. }
  273. function setVideoItem(num)
  274. {
  275.    trace("SET VIDEO ITEM");
  276.    loadVideo(videoResourceList,num);
  277.    trace("VIDEO ITEM TO BE LOADED=" + videoResourceList[num]);
  278.    videoWindow.videoSelector._visible = false;
  279.    selectorVisible = false;
  280. }
  281. function resolveVideoURL(url)
  282. {
  283.    var _loc11_ = System.capabilities.os;
  284.    if(_loc11_ != "MacOS")
  285.    {
  286.       return url;
  287.    }
  288.    var _loc5_ = _level0._url;
  289.    var _loc9_ = _loc5_.substr(0,4);
  290.    if(_loc9_ == "http")
  291.    {
  292.       return url;
  293.    }
  294.    var _loc10_ = _loc5_.indexOf("/Volumes/");
  295.    if(_loc10_ == -1)
  296.    {
  297.       return url;
  298.    }
  299.    var _loc7_ = String("file:///Volumes/").length;
  300.    var _loc12_ = _loc5_.substring(_loc7_);
  301.    var _loc3_ = _loc12_.split("/");
  302.    _loc3_.splice(_loc3_.length - 1,1);
  303.    var _loc4_ = url.split("/");
  304.    var _loc1_ = 0;
  305.    while(_loc1_ < _loc4_.length)
  306.    {
  307.       var _loc2_ = _loc4_[_loc1_];
  308.       if(_loc2_ == "..")
  309.       {
  310.          _loc3_.splice(_loc3_.length - 1,1);
  311.       }
  312.       else
  313.       {
  314.          _loc3_.push(_loc2_);
  315.       }
  316.       _loc1_ = _loc1_ + 1;
  317.    }
  318.    var _loc8_ = _loc3_.join(":");
  319.    return _loc8_;
  320. }
  321. var os = System.capabilities.os;
  322. trace(ostype);
  323. _global.delim = "";
  324. if(ostype.indexOf("Mac") == -1)
  325. {
  326.    _global.delim = "\\";
  327. }
  328. else
  329. {
  330.    _global.delim = "/";
  331. }
  332. var videoZoomed = false;
  333. var vidPath = "";
  334. var currentVideoPath = "";
  335. var videoResourceList = new Array();
  336. var menuMcs = new Array();
  337. var videoInitialised = false;
  338. var activeSection;
  339. var rootOpenFolderPath;
  340. myAppPath = mdm.Application.path;
  341. if(myAppPath == undefined)
  342. {
  343.    myAppPath = "";
  344. }
  345. var menuObject = new Array();
  346. menusPath = "menus" + _global.delim + "menu_items.txt";
  347. var st = "dsfd!";
  348. var activeSection = 0;
  349. var flvPlaying = false;
  350. videoWindow._visible = false;
  351. appPath = menusPath;
  352. var lv = new LoadVars();
  353. lv.onData = function(dat)
  354. {
  355.    appPath = dat;
  356.    makeMenus(dat);
  357.    trace(menuObject);
  358. };
  359. lv.load(menusPath);
  360. var infoLoader = new LoadVars();
  361. infoLoader.onData = function(txt)
  362. {
  363.    setInfoText(txt);
  364. };
  365. var selectorVisible = false;
  366.