//namespaces.. Object.g = new Object(); //global namespace //declare arrays for storing the box lists: Object.g.oneArr = new Array(); Object.g.Arr1 = new Array(); Object.g.Arr2 = new Array(); Object.g.Arr3 = new Array(); Object.g.Arr4 = new Array(); Object.g.Arr5 = new Array(); Object.g.Arr6 = new Array(); Object.g.Arr7 = new Array(); Object.g.Arr8 = new Array(); //declare arrays for storing the word info: Object.g.wArr = new Array(); Object.g.wArr[0] = new Array();//the actual word or phrase Object.g.wArr[1] = new Array();//the correct box for the word Object.g.wArr[2] = new Array();//the current box the word is in Object.g.wArr[3] = new Array();//the original x position of the word Object.g.wArr[4] = new Array();//the original y position of the word //distribute xml values to word Arrays: Object.g.numOfBoxes=colData.firstChild.childNodes[1].childNodes.length; //array for info on which pics have boxes. NOTE! Object.g.pic[0] is always zero and has no relevance if(Object.g.numOfBoxes<5){ var boxPicList=colData.firstChild.childNodes[0].childNodes[26].childNodes[0].nodeValue; Object.g.pic = boxPicList.split(','); } //------------------------------------------------------------------------- //modifiable elements: Object.g.insFeedback=colData.firstChild.childNodes[0].childNodes[19].childNodes[0].nodeValue; //instructions at beginning of game: Object.g.insTxt=colData.firstChild.childNodes[0].childNodes[0].childNodes[0].nodeValue; Object.g.instructionsColor=colData.firstChild.childNodes[0].childNodes[1].childNodes[0].nodeValue; Object.g.instructionsFontSize=colData.firstChild.childNodes[0].childNodes[2].childNodes[0].nodeValue; //background colour of game: Object.g.backColor=colData.firstChild.childNodes[0].childNodes[3].childNodes[0].nodeValue; //colour and size of words/phrases: Object.g.wordColor=colData.firstChild.childNodes[0].childNodes[4].childNodes[0].nodeValue; Object.g.wordFontSize=colData.firstChild.childNodes[0].childNodes[5].childNodes[0].nodeValue; Object.g.wordVSpace=colData.firstChild.childNodes[0].childNodes[17].childNodes[0].nodeValue; Object.g.bold=colData.firstChild.childNodes[0].childNodes[25].childNodes[0].nodeValue; //colour and size of the box titles and title box colour Object.g.titleColor=colData.firstChild.childNodes[0].childNodes[6].childNodes[0].nodeValue; Object.g.titleFontSize=colData.firstChild.childNodes[0].childNodes[7].childNodes[0].nodeValue; Object.g.boxTitleBackColor=colData.firstChild.childNodes[0].childNodes[8].childNodes[0].nodeValue; Object.g.boxTitleBorderColor = colData.firstChild.childNodes[0].childNodes[24].childNodes[0].nodeValue; //box colour Object.g.boxColor=colData.firstChild.childNodes[0].childNodes[9].childNodes[0].nodeValue; //check answer button text + button colour settings: Object.g.checkAnsBtnTxt=colData.firstChild.childNodes[0].childNodes[10].childNodes[0].nodeValue; Object.g.buttonTxtColor=colData.firstChild.childNodes[0].childNodes[11].childNodes[0].nodeValue; Object.g.buttonTxtFontSize=colData.firstChild.childNodes[0].childNodes[12].childNodes[0].nodeValue; Object.g.checkAnsBtnColor=colData.firstChild.childNodes[0].childNodes[13].childNodes[0].nodeValue; //Congratulatory text at end: Object.g.wDT = colData.firstChild.childNodes[0].childNodes[14].childNodes[0].nodeValue; Object.g.wDTColor = colData.firstChild.childNodes[0].childNodes[15].childNodes[0].nodeValue; Object.g.wDTFontSize = colData.firstChild.childNodes[0].childNodes[16].childNodes[0].nodeValue; Object.g.dragColour = colData.firstChild.childNodes[0].childNodes[18].childNodes[0].nodeValue; Object.g.naaText = colData.firstChild.childNodes[0].childNodes[20].childNodes[0].nodeValue; Object.g.naaColour = colData.firstChild.childNodes[0].childNodes[21].childNodes[0].nodeValue; Object.g.naaFontSize = colData.firstChild.childNodes[0].childNodes[22].childNodes[0].nodeValue; Object.g.naaBackColour = colData.firstChild.childNodes[0].childNodes[23].childNodes[0].nodeValue; //------------------------------------------------------------------------- Object.g.afArr = new Array(); for(gw=0;gw585){ _root[whatText+xsd].text=minusLastBlah; _root[whatText+xsd].setTextFormat(Object.g.phraseTextFormat); nextLine = sBlah[ssb-1]+" "; } //add the first piece of the extra text on the remainder of the line var firstCharR=_root[whatText+xsd].text.charAt(0) if ((firstCharR==".")||(firstCharR==",")||(firstCharR=="?")||(firstCharR=="!")){_root[whatText+xsd].text._x = Object.g.xPos-5;} else{_root[whatText+xsd]._x=Object.g.xPos;} Object.g.xPos += (_root[whatText+xsd]._width -10); //put together the remaining words for(ssx=ssb;ssx585){Object.g.xPos=10;Object.g.xtras("xtraText",Object.g.xtraNum)} //trace("xtras end"); trace("Object.g.yPos" + Object.g.yPos); trace("Object.g.xPos" + Object.g.xPos); } //----------------- Object.g.doAfA = function(dsd){ trace("afa"); trace("Object.g.yPos" + Object.g.yPos); //trace("Object.g.xPos" + Object.g.xPos); if(Object.g.afArr[dsd]!=null){ //create non-draggable text field _root.createTextField("blahText"+dsd,dsd,Object.g.xPos,Object.g.yPos,0,0); _root["blahText" + dsd].background=false; _root["blahText" + dsd].border=false; _root["blahText" + dsd].multiline=false; _root["blahText" + dsd].wordWrap=false; _root["blahText" + dsd].autoSize=true; _root["blahText" + dsd].leading=Object.g.wordVSpace; _root["blahText" + dsd].html=false; _root["blahText" + dsd].type="dynamic"; _root["blahText" + dsd].selectable=false; //to avoid double spacing delete the first space of any sentence var leadSpace = Object.g.afArr[dsd].indexOf(' '); if (leadSpace==0){_root["blahText"+dsd].text = Object.g.afArr[dsd].slice(1);} _root["blahText"+dsd].text = Object.g.afArr[dsd]; var firstChar=Object.g.afArr[dsd].charAt(0) if ((firstChar==".")||(firstChar==",")||(firstChar=="?")||(firstChar=="!")){_root["blahText"+dsd]._x = Object.g.xPos-5;} _root["blahText"+dsd].setTextFormat(Object.g.phraseTextFormat); var nextWidth=Object.g.xPos+_root["blahText"+dsd]._width; //if the text is too long for the remaining space in the line break it up: if(nextWidth>585){ Object.g.xtras("blahText",dsd); } else{Object.g.xPos += (_root["blahText"+dsd]._width -5);} } } //end of Object.g.doAfA //--------------------- //function for creating draggable text: Object.g.doWA = function(wsd){ trace("doWA"); trace("Object.g.yPos" + Object.g.yPos); //trace("Object.g.xPos" + Object.g.xPos); if(Object.g.wArr[0][wsd]!=null){ Object.g.dragTextFormat = new TextFormat(); Object.g.dragTextFormat.font = "Verdana"; Object.g.dragTextFormat.color = "0x"+Object.g.dragColour; Object.g.dragTextFormat.size = Object.g.wordFontSize; if(Object.g.bold==1){Object.g.dragTextFormat.bold = true;}else{Object.g.dragTextFormat.bold = false;} Object.g.greyTextFormat = new TextFormat(); Object.g.greyTextFormat.font = "Verdana"; Object.g.greyTextFormat.color = "0xCCCCCC"; Object.g.greyTextFormat.size = Object.g.wordFontSize; if(Object.g.bold==1){Object.g.greyTextFormat.bold = true;}else{Object.g.greyTextFormat.bold = false;} //to avoid double spacing delete the first space of any sentence _root.game.dragHolder.attachMovie("dWord", "dragSter"+wsd, wsd); _root.game.dragHolder["dragSter" + wsd].myText.autoSize=true; _root.game.dragHolder["dragSter" + wsd].text=Object.g.wArr[0][wsd]; _root.game.dragHolder["dragSter" + wsd].myText.setTextFormat(Object.g.dragTextFormat); _root.game.dragHolder["dragSter" + wsd]._x = Object.g.xPos; _root.game.dragHolder["dragSter" + wsd]._y = Object.g.yPos +1; //to avoid double spacing delete the first space of any sentence _root.game.greyHolder.attachMovie("gWord", "grey"+wsd, wsd); _root.game.greyHolder["grey" + wsd].myGreyText.autoSize=true; _root.game.greyHolder["grey" + wsd].text=Object.g.wArr[0][wsd]; _root.game.greyHolder["grey" + wsd].myGreyText.setTextFormat(Object.g.greyTextFormat); _root.game.greyHolder["grey" + wsd]._x = Object.g.xPos; _root.game.greyHolder["grey" + wsd]._y = Object.g.yPos +1 Object.g.wArr[2].push(0); Object.g.wArr[3][wsd]=Object.g.xPos; Object.g.wArr[4][wsd]=Object.g.yPos; setProperty(_root.game.dragHolder["dragSter" + wsd].dFalso, _width, _root.game.dragHolder["dragSter"+wsd].myText._width); _root.game.greyHolder["grey" + wsd]._width=_root.game.greyHolder["grey"+wsd].myText._width; //make sure the button to be hit for dragging is the same size as the text: _root.game.dragHolder["dragSter"+wsd]._height=_root.game.dragHolder["dragSter"+wsd].myText._height; var nextDWidth=(Object.g.xPos+_root.game.dragHolder["dragSter"+wsd].myText._width); //if adding the draggable word will not fit the remaining space on the line then put it on the next line if(nextDWidth>585){ Object.g.yPos+=_root.game.dragHolder["dragSter"+wsd]._height-5; Object.g.xPos=10; _root.game.dragHolder["dragSter"+wsd]._y=Object.g.yPos +1; _root.game.dragHolder["dragSter"+wsd]._x=Object.g.xPos; _root.game.greyHolder["grey"+wsd]._y=Object.g.yPos +1; _root.game.greyHolder["grey"+wsd]._x=Object.g.xPos; Object.g.wArr[3][wsd]=Object.g.xPos; Object.g.wArr[4][wsd]=Object.g.yPos; } Object.g.xPos += (_root.game.dragHolder["dragSter"+wsd].myText._width-1); trace("Object.g.xPos: " + Object.g.xPos); //dragN++; } } //end of Object.g.doWA() //----------- //function to split the original inputted text into pieces of words to be dragged or not Object.g.doTheSplits = function(){ Object.g.phraseTextFormat = new TextFormat(); Object.g.phraseTextFormat.font = "Verdana"; Object.g.phraseTextFormat.color = "0x"+Object.g.wordColor; Object.g.phraseTextFormat.size = Object.g.wordFontSize; if(Object.g.bold==1){Object.g.phraseTextFormat.bold = true;}else{Object.g.phraseTextFormat.bold = false;} Object.g.phraseTextFormat.leading=Object.g.wordVSpace; if(Object.g.wArr[0][0]==null){ Object.g.xPos=10;Object.g.yPos=0; var dragN = 0; for(sd=0;sd=1;c--){ _root.game["boxes"+Object.g.numOfBoxes+"_box"+c+"_title"].text = unescape(colData.firstChild.childNodes[1].childNodes[c-1].childNodes[0].childNodes[0].nodeValue); _root.game["boxes"+Object.g.numOfBoxes+"_box"+c+"_title"].setTextFormat(titleTextFormat); //set the background colour for the title boxes: //_root.game["boxes"+Object.g.numOfBoxes+"_box"+c+"_title"].border = true; _root.game["boxes"+Object.g.numOfBoxes+"_box"+c+"_title"].borderColor = "0x" + Object.g.boxTitleBorderColor; trace("Object.g.boxTitleBorderColor" + Object.g.boxTitleBorderColor); _root.game["boxes"+Object.g.numOfBoxes+"_box"+c+"_title"].backgroundColor = "0x" +Object.g.boxTitleBackColor; //set background colour for boxes boxBackColor = new Color(_root.game["boxes"+Object.g.numOfBoxes+"_box"+c]); boxBackColor.setRGB("0x"+Object.g.boxColor); } //set the text and colour on the 'check answers' button _root.game.checkB.ansButtonTxt.text=Object.g.checkAnsBtnTxt; buttonTextFormat = new TextFormat(); buttonTextFormat.color = "0x"+Object.g.buttonTxtColor; buttonTextFormat.size = Object.g.buttonTxtFontSize; _root.game.checkB.ansButtonTxt.setTextFormat(buttonTextFormat); cbColor = new Color(_root.game.checkB.cbFilCol); cbColor.setRGB("0x"+Object.g.checkAnsBtnColor); Object.g.doTheSplits(); } //generate game end //-------------------------------- //loadFunction //rev :: 03/04/2002 :: use with swf Q //define Loader Object.g.loadBar = function (lo) { // set up a loader function!! _root.pLoad._visible = true; _root.pLoad.pLoadText = "Preloading: " + lo.lkb + "k of " + lo.tkb + "k"; if (lo.perCent > 1 && lo.perCent < 100 ) { _root.pLoad.loaderBar_mc._xscale=100 - lo.perCent; } if (lo.loadStatus=="finished") { _root.pLoad._visible = false; //trace("loadBar: lo.loadStatus: " + lo.loadStatus); } } //button selection function Object.g.doButton = function (val) { trace("Object.g.doButton: " + val); //start if (val=="start") {_root.gotoAndStop("go");Object.g.generateGame();} } //--------------------------------------------------- //-------------------------------- //move a word around with the mouse: Object.g.dontDrag=0; Object.g.moveWord = function (whichWord){ if(Object.g.dontDrag==0){ var word = _root.game.dragHolder[whichWord]; theMouseListener = new Object(); theMouseListener.onMouseMove = function () { //if it was off-screen then reposition it on-screen word._x = (_root._xmouse - (word._width/2)); word._y = (_root._ymouse - (word._height/2)); // trace("x: " + _root._xmouse + "y: " + _root._ymouse); if (word._x < 25){word._x = 25} if (word._x > 550){word._x = 550} if (word._y < -1){word._y = 20} if (word._y > 400){word._y = 400} } Mouse.addListener(theMouseListener); } Object.g.dropWord = function (whichWord){ if(Object.g.dontDrag==0){ Mouse.removeListener (theMouseListener); Object.g.whereIsIt(whichWord); } } } //redraw the lists Object.g.rackEmUp = function(arrayNum,deleteA){ //if(arrayNum<5){var listY=185;}else{var listY=305;} switch(arrayNum){ case 1: var listX=150; var yLimit=310; var listY=276; if(Object.g.numOfBoxes==1){listX=300} if(Object.g.numOfBoxes==2){listX+=80} if(Object.g.numOfBoxes==3){listX+=30} if(Object.g.numOfBoxes>5){yLimit=245} break; case 2: var listX=150; var yLimit=400; var listY=356; if(Object.g.numOfBoxes==2){listX+=223} if(Object.g.numOfBoxes==3){listX+=76} if(Object.g.numOfBoxes>6){yLimit=245} break; case 3: var listX=450; var yLimit=310; var listY=276; if(Object.g.numOfBoxes==3){listX+=123} if(Object.g.numOfBoxes>6){yLimit=245} break; case 4: var listX=450; var yLimit=400; var listY=356; if(Object.g.numOfBoxes>4){yLimit=245} break; case 5: var listX=450; var yLimit=400; var listY=356; if(Object.g.numOfBoxes>5){listX=70} break; case 6: var listX=520; var yLimit=370; if(Object.g.numOfBoxes==7){listX=300} if(Object.g.numOfBoxes==8){listX=222} break; case 7: var listX=520; var yLimit=370; if(Object.g.numOfBoxes==8){listX=372} break; case 8: var listX=520; var yLimit=370; break; } if(deleteA!=null){ trace("deleteA"+deleteA); for(e=0;e0){listY+=(number(Object.g.wordFontSize) + number(Object.g.wordVSpace))}else{listY+=number(Object.g.wordFontSize)} } } for(e=0;e0){listY+=(number(Object.g.wordFontSize) + number(Object.g.wordVSpace))}else{listY+=number(Object.g.wordFontSize)} } trace("rack Object.g.wArr[2] :" + Object.g.wArr[2]); trace("rack Object.g.wArr[0] :" + Object.g.wArr[0]); } //---------------------------------------- //work out where word was dropped: Object.g.whereIsIt = function(word){ var splitWordAndNumber = word.split('dragSter'); trace("splitWordAndNumber[0]: " + splitWordAndNumber[0] + "splitWordAndNumber[1]" + splitWordAndNumber[1]); var wordNumber = splitWordAndNumber[1]; var wrd = _root.game.dragHolder['dragSter'+wordNumber]; var wX=(wrd._x + (_root.game.dragHolder[wN]._width/2)); var wY=(wrd._y + (_root.game.dragHolder[wN]._height/2)); //was it dropped on one of the 'boxes' (target areas)? Object.g.where="nowhere"; switch(Object.g.numOfBoxes){ case 1: if (((wX > 160)&&(wX < 435))&&((wY > 145)&&(wY < 360))){Object.g.where=1;} break; case 2: if (((wX > 10)&&(wX < 290))&&((wY > 145)&&(wY < 360))){Object.g.where=1;} if (((wX > 310)&&(wX < 580))&&((wY > 145)&&(wY < 360))){Object.g.where=2;} break; case 3: if (((wX > 10)&&(wX < 190))&&((wY > 145)&&(wY < 360))){Object.g.where=1;} if (((wX > 210)&&(wX < 390))&&((wY > 145)&&(wY < 360))){Object.g.where=2;} if (((wX > 410)&&(wX < 580))&&((wY > 145)&&(wY < 360))){Object.g.where=3;} break; case 4: if (((wX > -10)&&(wX < 290))&&((wY > 270)&&(wY < 315))){Object.g.where=1;} if (((wX > -10)&&(wX < 290))&&((wY > 350)&&(wY < 395))){Object.g.where=2;} if (((wX > 300)&&(wX < 430))&&((wY > 270)&&(wY < 315))){Object.g.where=3;} if (((wX > 300)&&(wX < 585))&&((wY > 350)&&(wY < 395))){Object.g.where=4;} break; case 5: if (((wX > -10)&&(wX < 290))&&((wY > 270)&&(wY < 315))){Object.g.where=1;} if (((wX > -10)&&(wX < 290))&&((wY > 350)&&(wY < 395))){Object.g.where=2;} if (((wX > 140)&&(wX < 430))&&((wY > 430)&&(wY < 475))){Object.g.where=3;} if (((wX > 300)&&(wX < 585))&&((wY > 270)&&(wY < 315))){Object.g.where=4;} if (((wX > 300)&&(wX < 585))&&((wY > 350)&&(wY < 395))){Object.g.where=5;} break; case 6: if (((wX > -10)&&(wX < 140))&&((wY > 145)&&(wY < 240))){Object.g.where=1;} if (((wX > 160)&&(wX < 290))&&((wY > 145)&&(wY < 360))){Object.g.where=2;} if (((wX > 310)&&(wX < 435))&&((wY > 145)&&(wY < 360))){Object.g.where=3;} if (((wX > 460)&&(wX < 585))&&((wY > 145)&&(wY < 240))){Object.g.where=4;} if (((wX > -10)&&(wX < 140))&&((wY > 265)&&(wY < 395))){Object.g.where=5;} if (((wX > 460)&&(wX < 585))&&((wY > 265)&&(wY < 395))){Object.g.where=6;} break; case 7: if (((wX > -10)&&(wX < 140))&&((wY > 145)&&(wY < 240))){Object.g.where=1;} if (((wX > 160)&&(wX < 290))&&((wY > 145)&&(wY < 240))){Object.g.where=2;} if (((wX > 310)&&(wX < 435))&&((wY > 145)&&(wY < 240))){Object.g.where=3;} if (((wX > 460)&&(wX < 585))&&((wY > 145)&&(wY < 240))){Object.g.where=4;} if (((wX > -10)&&(wX < 140))&&((wY > 265)&&(wY < 395))){Object.g.where=5;} if (((wX > 160)&&(wX < 435))&&((wY > 265)&&(wY < 360))){Object.g.where=6;} if (((wX > 460)&&(wX < 585))&&((wY > 265)&&(wY < 395))){Object.g.where=7;} break; case 8: if (((wX > -10)&&(wX < 140))&&((wY > 145)&&(wY < 240))){Object.g.where=1;} if (((wX > 160)&&(wX < 290))&&((wY > 145)&&(wY < 240))){Object.g.where=2;} if (((wX > 310)&&(wX < 435))&&((wY > 145)&&(wY < 240))){Object.g.where=3;} if (((wX > 460)&&(wX < 585))&&((wY > 145)&&(wY < 240))){Object.g.where=4;} if (((wX > -10)&&(wX < 140))&&((wY > 265)&&(wY < 395))){Object.g.where=5;} if (((wX > 160)&&(wX < 290))&&((wY > 265)&&(wY < 360))){Object.g.where=6;} if (((wX > 310)&&(wX < 435))&&((wY > 265)&&(wY < 360))){Object.g.where=7;} if (((wX > 460)&&(wX < 585))&&((wY > 265)&&(wY < 395))){Object.g.where=8;} break; } trace("theWord: " + wrd + "Object.g.where" + Object.g.where); if (Object.g.where=="nowhere"){ _root.game.dragHolder['dragSter'+wordNumber]._x=Object.g.wArr[3][wordNumber]; _root.game.dragHolder['dragSter'+wordNumber]._y=Object.g.wArr[4][wordNumber]+1; Object.g.wArr[2][wordNumber]=0;} else{ if(Object.g.insFeedback==1){ if(Object.g.where!=Object.g.wArr[1][wordNumber]){ _root.game.dragHolder['dragSter'+wordNumber]._x=Object.g.wArr[3][wordNumber]; _root.game.dragHolder['dragSter'+wordNumber]._y=Object.g.wArr[4][wordNumber]+1; Object.g.wArr[2][wordNumber]=0; Object.g.where="nowhere"; } else{ Object.g.wArr[2][wordNumber]=Object.g.where; var doCheck=0; for(owa=0;owa