home *** CD-ROM | disk | FTP | other *** search
/ Dermatology Step by Step / Dermatology Step by Step.iso / pc / Media / Dermatology / Algorithm.swf / scripts / frame_1 / DoAction.as < prev   
Encoding:
Text File  |  2001-02-15  |  7.8 KB  |  346 lines

  1. function desactivateButton()
  2. {
  3.    varx = algoToFreezeButton.charAt(0);
  4.    vary = algoToFreezeButton.charAt(1);
  5.    i = 1;
  6.    while(nb_Answer >= i)
  7.    {
  8.       _root["C" + varx + "_" + vary]["D" + varx + vary + "_" + i].gotoAndStop("done");
  9.       i++;
  10.    }
  11. }
  12. function getNextQuestion()
  13. {
  14.    if(testNo < 4)
  15.    {
  16.       testNo++;
  17.    }
  18.    else
  19.    {
  20.       _level0.TestIsDone = 4;
  21.       _level0.saveUserData();
  22.       loadMovieNum("InstructionPosttest.swf",34,"GET");
  23.    }
  24.    isPostest = 0;
  25.    testToLoad = _root.Question[testno];
  26.    myData.loadVariables(getFile("test",testToLoad));
  27.    myData.myFrame = "algorithm";
  28.    myData.smallPict = getFile("pictS",testToLoad);
  29.    myData.largePict = getFile("pictL",testToLoad);
  30.    Qflashed = false;
  31. }
  32. function turn(toState, objArray1, objArray2, objArray3, objArray4, objArray5)
  33. {
  34.    var i = 0;
  35.    while(i < objArray1.length)
  36.    {
  37.       objArray1[i].gotoAndStop(toState);
  38.       i++;
  39.    }
  40.    var i = 0;
  41.    while(i < objArray2.length)
  42.    {
  43.       objArray2[i].gotoAndStop(toState);
  44.       i++;
  45.    }
  46.    var i = 0;
  47.    while(i < objArray3.length)
  48.    {
  49.       objArray3[i].gotoAndStop(toState);
  50.       i++;
  51.    }
  52.    var i = 0;
  53.    while(i < objArray4.length)
  54.    {
  55.       objArray4[i].gotoAndStop(toState);
  56.       i++;
  57.    }
  58.    var i = 0;
  59.    while(i < objArray5.length)
  60.    {
  61.       objArray5[i].gotoAndStop(toState);
  62.       i++;
  63.    }
  64.    if(toState == "off")
  65.    {
  66.       mc_mainFeedback.gotoAndStop(1);
  67.    }
  68. }
  69. function getFile(type, ID)
  70. {
  71.    var file = "";
  72.    if(type == "info")
  73.    {
  74.       file = "_data/algorithm/getAlgorithmInfo_" + ID + ".txt";
  75.    }
  76.    if(type == "test")
  77.    {
  78.       file = "_data/algorithm/getAlgorithmInfo_F" + ID + ".swf";
  79.    }
  80.    if(type == "pictS")
  81.    {
  82.       file = "_media/algorithm/T/imgs_0" + ID + ".swf";
  83.    }
  84.    if(type == "pictL")
  85.    {
  86.       file = "_media/algorithm/T/imgL_0" + ID + ".swf";
  87.    }
  88.    return file;
  89. }
  90. function getInfoDataFile(infoBtn)
  91. {
  92.    return "_data/algorithm/getAlgorithmInfo_" + infoBtn._name + ".txt";
  93. }
  94. function getFeedbacks(classDisease)
  95. {
  96. }
  97. function setThumbPict(dropzone)
  98. {
  99.    dropzone.loadMovie(myData.smallPict);
  100. }
  101. function setZoomPict(dropzone)
  102. {
  103.    dropzone.loadMovie(myData.largePict);
  104. }
  105. function showInfo(button)
  106. {
  107.    var ID = button._name;
  108.    if(ID != "mc_help")
  109.    {
  110.       var mPath = "_media/algorithm/" + ID.charAt(0) + "/";
  111.       var frame = "info" + ID.charAt(0);
  112.       var dataFile = getFile("info",ID);
  113.    }
  114.    else
  115.    {
  116.       var mPath = "help";
  117.    }
  118.    _level0.algorithmInf = {myCaller:_root,myFrame:frame,myMoviePath:mPath,myDataFile:dataFile};
  119.    loadMovieNum("algorithmInf.swf",50,"GET");
  120. }
  121. function showFeedback(button)
  122. {
  123.    if(_root.isTestMode)
  124.    {
  125.       var btnNo = Number(button._name.split("_")[1]);
  126.       var rightAnswer = btnNo == Number(myData.ID[1]);
  127.       if(_root.BtnClicked2[_root.testno][btnNo] != 1)
  128.       {
  129.          _root.counter_choice2 = _root.counter_choice2 + 1;
  130.          if(RightAnswer == true and _level0.Algo_Question_Done2[_root.testno] != 1)
  131.          {
  132.             _root.BtnClicked2[_root.testno][btnNo] = 1;
  133.             _level0.Algo_Question_Done2[_root.testno] = 1;
  134.             _level0.User_Choice_Algo2[_root.testno][_root.counter_choice2] = btnNo;
  135.             _level0.saveTestData();
  136.          }
  137.          if(_root.counter_choice2 < _root.nb_Answer and _level0.Algo_Question_Done2[_root.testno] != 1)
  138.          {
  139.             _root.BtnClicked2[_root.testno][btnNo] = 1;
  140.             _level0.User_Choice_Algo2[_root.testNo][_root.counter_choice2] = btnNo;
  141.             _level0.saveTestData();
  142.          }
  143.       }
  144.       mc_feedback.title = filter(button.text,"\r");
  145.       mc_feedback.text = myData["D" + btnNo];
  146.       mc_feedback.gotoAndStop(!rightAnswer ? "wrong" : "right");
  147.    }
  148. }
  149. function filter(str1, str2, maxChr)
  150. {
  151.    str2 = str1.split(str2);
  152.    str1 = "";
  153.    var n = 0;
  154.    while(n < str2.length)
  155.    {
  156.       str1 += str2[n] + " ";
  157.       n++;
  158.    }
  159.    str1 = str1.substr(0,str1.length - 1);
  160.    if(typeof maxChr != "undefined")
  161.    {
  162.       str1 = str1.substr(0,maxChr) + "...";
  163.    }
  164.    return str1;
  165. }
  166. function replace(str, str1, str2)
  167. {
  168.    var string = "";
  169.    var index = str.indexOf(str1);
  170.    while(-1 < index)
  171.    {
  172.       string += str.substr(0,index) + str2;
  173.       str = str.substr(index + str1.length,str.length);
  174.       index = str.indexOf(str1);
  175.    }
  176.    string += str;
  177.    return string;
  178. }
  179. function addToButtonList(btnMC)
  180. {
  181.    var n = 0;
  182.    found = false;
  183.    if(typeof buttonList == "undefined")
  184.    {
  185.       buttonList = [];
  186.    }
  187.    while(!found && n < buttonList.length)
  188.    {
  189.       found = buttonList[n] == btnMC;
  190.       n++;
  191.    }
  192.    if(!found)
  193.    {
  194.       buttonList.push(btnMC);
  195.    }
  196. }
  197. function removeFromButtonList(btnMC)
  198. {
  199.    var n = 0;
  200.    while(n < buttonList.length)
  201.    {
  202.       if(buttonList[n] == btnMC)
  203.       {
  204.          buttonList.splice(n,1);
  205.          break;
  206.       }
  207.       n++;
  208.    }
  209. }
  210. function freeze()
  211. {
  212.    with(mc_mainAlgorithm.startBtn)
  213.    {
  214.       _root.turn("toff",myQ,myA,myC);
  215.    }
  216.    var n = 0;
  217.    while(n < buttonList.length)
  218.    {
  219.       buttonList[n].freeze();
  220.       n++;
  221.    }
  222. }
  223. function unfreeze()
  224. {
  225.    with(mc_mainAlgorithm.startBtn)
  226.    {
  227.       _root.turn("rollout",myQ,myA,myC);
  228.    }
  229.    var n = 0;
  230.    while(n < buttonList.length)
  231.    {
  232.       buttonList[n].unfreeze();
  233.       n++;
  234.    }
  235. }
  236. function doClose()
  237. {
  238.    _level0.unfreezePreviousLevelAndUnStack(_root);
  239.    _root.unloadMovie();
  240. }
  241. function convertToBinary(number)
  242. {
  243.    var result = "";
  244.    var i = 0;
  245.    while(i < 32)
  246.    {
  247.       var lsb = number & 1;
  248.       result = (!lsb ? "0" : "1") + result;
  249.       number >>= 1;
  250.       i++;
  251.    }
  252.    return result.substr(21,12);
  253. }
  254. function convertToDecimal(number)
  255. {
  256.    var result = 0;
  257.    nbChr = number.length;
  258.    var i = 0;
  259.    while(i < nbChr)
  260.    {
  261.       result += number.charAt(nbChr - 1 - i) != 1 ? 0 : Math.pow(2,i);
  262.       i++;
  263.    }
  264.    return result;
  265. }
  266. function verify_Pretest_Question()
  267. {
  268.    _root.Question = [];
  269.    counter = 0;
  270.    i = 1;
  271.    while(i < 5)
  272.    {
  273.       if(_root.answer[i] != _level0.User_Choice_Pretest[i])
  274.       {
  275.          counter++;
  276.          _root.Question[counter] = i;
  277.       }
  278.       i++;
  279.    }
  280.    counter2 = 4 - counter;
  281.    while(counter < 5)
  282.    {
  283.       counter++;
  284.       _root.Question[counter] = counter2 + counter;
  285.    }
  286. }
  287. function Last_Question_Done()
  288. {
  289.    _root.No_Essai = [];
  290.    _root.No_Essai2 = [];
  291.    _root.BtnClicked = new Array(5);
  292.    _root.BtnClicked[1] = new Array(10);
  293.    _root.BtnClicked[2] = new Array(10);
  294.    _root.BtnClicked[3] = new Array(10);
  295.    _root.BtnClicked[4] = new Array(10);
  296.    _root.BtnClicked2 = new Array(5);
  297.    _root.BtnClicked2[1] = new Array(10);
  298.    _root.BtnClicked2[2] = new Array(10);
  299.    _root.BtnClicked2[3] = new Array(10);
  300.    _root.BtnClicked2[4] = new Array(10);
  301.    counter = 0;
  302.    _root.Which_Question = 1;
  303.    i = 1;
  304.    while(i < 5)
  305.    {
  306.       if(_level0.Algo_Question_Done[i] == 1)
  307.       {
  308.          if(_level0.Algo_Question_Done2[i] == 1)
  309.          {
  310.             counter++;
  311.             _root.Which_Question = 1;
  312.          }
  313.          else
  314.          {
  315.             _root.Which_Question = 2;
  316.          }
  317.       }
  318.       i++;
  319.    }
  320.    _root.testno = counter;
  321.    i = 1;
  322.    while(i < 5)
  323.    {
  324.       counter = 1;
  325.       while(_level0.User_Choice_Algo[i][counter] != "" and _level0.User_Choice_Algo[i][counter] != null)
  326.       {
  327.          _root.BtnClicked[i][_level0.User_Choice_Algo[i][counter]] = 1;
  328.          counter++;
  329.       }
  330.       _root.No_Essai[i] = counter - 1;
  331.       i++;
  332.    }
  333.    i = 1;
  334.    while(i < 5)
  335.    {
  336.       counter = 1;
  337.       while(_level0.User_Choice_Algo2[i][counter] != "" and _level0.User_Choice_Algo2[i][counter] != null)
  338.       {
  339.          _root.BtnClicked2[i][_level0.User_Choice_Algo[i][counter]] = 1;
  340.          counter++;
  341.       }
  342.       _root.No_Essai2[i] = counter - 1;
  343.       i++;
  344.    }
  345. }
  346.