startPlaceFlag=1; startNumber=1; //xOrigin = 140; //yOrigin = 15; gridNumber = 0; rowLength = 10; maxNumber = startNumber+129; numberIncrement = 1; maxNumberDifference = 0; xPosition = 0; yPosition = 0; thisMouseSquareNumber = 0; thisFactor = 1; maskSquaresArray = new Array(); maskSquaresTempArray = new Array(); maskStartPlace = 1; maskCoverFlag = 0; maskBgFlag = 0; maxUpSquares=0; maxDownSquares=6; maxLeftSquares=0; maxRightSquares=6; virginFlag=0; factorsNumber=0; rowFlagArray = new Array (0,0,0,0,0,0,0,0,0,0,0); colFlagArray = new Array (0,0,0,0,0,0,0,0,0,0,0,0,0,0); primesArray = new Array (0,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131) primesNumber = 1; lastFrame = 20; secondColourFlag = 1; coverFlag=0; function writeTheNumbers (maxNumber, rowLength) { if(startPlaceFlag == 1){ thisYPlace = 0; } else{ thisYPlace = 270; } thisXPlace = -20; rowPixels = rowLength*30; for (newSquares=_root.startNumber; newSquares<=maxNumber; newSquares++) { _root.thisXPlace = _root.thisXPlace+30; if (_root.thisXPlace>=rowPixels+10) { _root.thisXPlace = 10; _root.thisYPlace = _root.thisYPlace+(startPlaceFlag*30); } duplicateMovieClip (_root.numberGrid.numberSquare, "numberSquare"+newSquares,_root.maxNumber - newSquares); if(newSquares <= (_root.startNumber+_root.rowLength*10-1)) { _root.numberGrid["numberSquare"+newSquares]._x = _root.thisXPlace; _root.numberGrid["numberSquare"+newSquares]._y = _root.thisYPlace; } _root.numberGrid["numberSquare"+newSquares].coverLayer._alpha=0; _root.numberGrid["numberSquare"+newSquares].myColourNumber=0; _root.numberGrid["numberSquare"+newSquares].numberPlace = newSquares; //---define blue number --- _root.numberGrid["numberSquare"+newSquares].blueText_mc.numberPlace = newSquares; } duplicateMovieClip (_root.numberCover, "numberCover", newSquares); } function clearTheNumbers (maxNumber) { for (deadSquares=_root.maxNumber; deadSquares>=_root.startNumber; deadSquares--) { removeMovieClip ("numberGrid.numberSquare"+deadSquares); } } function moveTheNumbers (maxNumber, rowLength) { theseRows = 1; for (oldSquares=(maxNumber+1); oldSquares<=(maxNumber+maxNumberDifference); oldSquares++) { _root.numberGrid["numberSquare"+oldSquares]._x = 212; _root.numberGrid["numberSquare"+oldSquares]._y = 354; } if(startPlaceFlag == 1){ thisYPlace = 0; } else{ thisYPlace = 270; } thisXPlace = -20; rowPixels = rowLength*30; for (newSquares=_root.startNumber; newSquares<=_root.maxNumber; newSquares++) { _root.thisXPlace = _root.thisXPlace+30; if (_root.thisXPlace >= rowPixels+10) { _root.thisXPlace = 10//_root.thisXPlace-rowPixels; _root.thisYPlace = _root.thisYPlace+(startPlaceFlag*30); theseRows = theseRows+1; } if (theseRows<=10) { _root.numberGrid["numberSquare"+newsquares]._x = _root.thisXPlace; _root.numberGrid["numberSquare"+newsquares]._y = _root.thisYPlace; } else { _root.numberGrid["numberSquare"+newSquares]._x = 212; _root.numberGrid["numberSquare"+newSquares]._y = 354; } } if(_root.maskCoverFlag==1) { _root.placeMask() } } function coverAllNumbers() { for(n=_root.startNumber; n<=_root.maxNumber; n++) { _root.numberGrid["numberSquare"+n].coverLayer._alpha = 100; _root.numberGrid["numberSquare"+n].myColourNumber = 4; } } function uncoverAllNumbers() { for(n=_root.startNumber; n<=_root.maxNumber; n++) { _root.numberGrid["numberSquare"+n].coverLayer._alpha = 0; } } function clearColours() { for(n=_root.startNumber; n<=_root.maxNumber; n++) { _root.numberGrid["numberSquare"+n].blueLayer._alpha = 100; _root.numberGrid["numberSquare"+n].redLayer._alpha = 100; _root.numberGrid["numberSquare"+n].redLayer.yellowBlock_mc._alpha = 100 _root.numberGrid["numberSquare"+n].greenLayer._alpha = 100; _root.numberGrid["numberSquare"+n].blueText_mc._alpha = 0 } } function colourSquare(thisSquare){ thisSquare.blueLayer._alpha = 0; thisSquare.redLayer._alpha = 0; thisSquare.redLayer.yellowBlock_mc._alpha = 0 thisSquare.greenLayer._alpha = 0; thisSquare.myColourNumber = secondColourFlag; if(secondColourFlag == 1){ thisSquare.redLayer._alpha = 100; thisSquare.redLayer.yellowBlock_mc._alpha = 100 } if(secondColourFlag == 2){ thisSquare.greenLayer._alpha = 100; } if(secondColourFlag == 4){ thisSquare.coverLayer._alpha = 100; } } function colourFactors(startNumber) { nextFactor = startNumber; _root.factorsNumber = _root.factorsNumber + 1; do { if(_root.factorsNumber ==1) { _root.numberGrid["numberSquare"+nextFactor].blueLayer._alpha = 0; _root.numberGrid["numberSquare"+nextFactor].blueText_mc._alpha = 100; _root.numberGrid["numberSquare"+nextFactor].myColourNumber = 1; } if(_root.factorsNumber ==2) { if(_root.numberGrid["numberSquare"+nextFactor].blueLayer._alpha < 10) { _root.numberGrid["numberSquare"+nextFactor].redLayer.yellowBlock_mc._alpha = 0; _root.numberGrid["numberSquare"+nextFactor].myColourNumber = 1; } else { _root.numberGrid["numberSquare"+nextFactor].blueLayer._alpha = 0; _root.numberGrid["numberSquare"+nextFactor].redLayer._alpha = 0; _root.numberGrid["numberSquare"+nextFactor].blueText_mc._alpha = 100; _root.numberGrid["numberSquare"+nextFactor].myColourNumber = 0; } } if (_root.factorsNumber >=3) { if(_root.numberGrid["numberSquare"+nextFactor].redLayer.yellowBlock_mc._alpha < 50) { _root.numberGrid["numberSquare"+nextFactor].greenLayer._alpha = 30; _root.numberGrid["numberSquare"+nextFactor].blueText_mc._alpha = 100; _root.numberGrid["numberSquare"+nextFactor].myColourNumber = 3; } else { _root.numberGrid["numberSquare"+nextFactor].blueLayer._alpha = 0; _root.numberGrid["numberSquare"+nextFactor].redLayer._alpha = 0; _root.numberGrid["numberSquare"+nextFactor].greenLayer._alpha = 0; _root.numberGrid["numberSquare"+nextFactor].myColourNumber = 3; _root.numberGrid["numberSquare"+nextFactor].blueText_mc._alpha = 100; } } nextFactor = nextFactor + startNumber } while(nextFactor <= _root.maxNumber) } function resetAll() { gridNumber = 0; maxNumber = startNumber+129; //numberIncrement = 1; maxNumberDifference = 0; xPosition = 0; yPosition = 0; //thisMouseSquareNumber = 0; SthisFactor = 1 _root.moveTheNumbers(_root.maxNumber, _root.rowLength); _root.clearColours(); _root.clearMaskSquares(); _root.uncoverAllNumbers(); _root.maskCoverFlag=0; _root.controls_04_mc.maskSquareBackground.maskSquareCover._alpha = 0; _root.maskBgFlag=0; _root.resetDirectionSquares(); _root.factorsNumber=0; for(n=1; n<=10; n++) { _root.rowFlagArray[n] = 0; } for(n=1; n<=13; n++) { _root.colFlagArray[n] = 0 } } function clearMaskSquares() { for(sq=1; sq<=16; sq++) { _root.controls_04_mc["maskSquare_" + sq].maskSquareCover._alpha = 0 } } function toggleMaskSquares() { if(maskBgFlag == 1) { _root.controls_04_mc.maskSquareBackground.maskSquareCover._alpha = 0; maskBgFlag=0 } else{ _root.controls_04_mc.maskSquareBackground.maskSquareCover._alpha = 100; maskBgFlag=1 } for(sq=1; sq<=16; sq++) { if(_root.controls_04_mc["maskSquare_" + sq].maskSquareCover._alpha == 0) { _root.controls_04_mc["maskSquare_" + sq].maskSquareCover._alpha = 100; } else { _root.controls_04_mc["maskSquare_" + sq].maskSquareCover._alpha = 0; } } _root.getMaskSquaresArray() } function getMaskSquaresArray() { for(sq=1; sq<=16; sq++) { if(_root.controls_04_mc["maskSquare_" + sq].maskSquareCover._alpha == 0) { _root.maskSquaresArray[sq] = 0 } else { _root.maskSquaresArray[sq] = 1 } } } function turnNinetyDegrees() { thisTempSq=1; for(sq=13; sq<=16; sq++) { for(thisSq = sq; thisSq > 0; thisSq = thisSq-4) { _root.maskSquaresTempArray[thisTempSq] = _root.maskSquaresArray[thisSq]; thisTempSq = thisTempSq + 1; } } // _root.maskSquaresArray=_root.maskSquaresTempArray; for(sq=1; sq<=16; sq++) { if(_root.maskSquaresTempArray[sq] == 1) { _root.controls_04_mc["maskSquare_" + sq].maskSquareCover._alpha = 100 } else { _root.controls_04_mc["maskSquare_" + sq].maskSquareCover._alpha = 0 } } } function placeMask() { if(maskBgFlag == 1) { coverAllNumbers() } else { uncoverAllNumbers() } maskSq = 1; nextSq = _root.maskStartPlace; for(thisRow=1; thisRow<=4; thisRow++) { for(thisSq=1; thisSq<=4; thisSq++) { if(_root.controls_04_mc["maskSquare_" + maskSq].maskSquareCover._alpha == 100 ) { _root.numberGrid["numberSquare" + nextSq].coverLayer._alpha = 100 } else { _root.numberGrid["numberSquare" + nextSq].coverLayer._alpha = 0 } nextSq = nextSq+1; maskSq = maskSq+1 } nextSq = nextSq + rowLength - 4 } } function maskUp() { _root.maskStartPlace = _root.maskStartPlace - _root.rowLength; placeMask() } function maskDown() { _root.maskStartPlace = _root.maskStartPlace + _root.rowLength; placeMask() } function maskRight() { _root.maskStartPlace = _root.maskStartPlace + 1; placeMask() } function maskLeft() { _root.maskStartPlace = _root.maskStartPlace - 1; placeMask() } function resetDirectionSquares() { _root.maskStartPlace = _root.startNumber _root.maxUpSquares=0; _root.maxDownSquares=6; _root.maxLeftSquares=0; _root.maxRightSquares=_root.rowLength-4; } function selectRow(thisRow) { if(_root.selectColumnCover._alpha < 10) { rowFlagArray[thisRow] = 1; rowStartSquare = _root.startNumber+((thisRow -1)*_root.rowLength); for(thisSquare = rowStartSquare; thisSquare < (rowStartSquare + _root.rowLength); thisSquare++ ) { if(_root.coverFlag==1){ _root.numberGrid["numberSquare"+thisSquare].blueLayer._alpha = 0; _root.numberGrid["numberSquare"+thisSquare].blueText_mc._alpha = 100; _root.numberGrid["numberSquare"+thisSquare].myColourNumber = 1; } if(_root.coverFlag==2){ _root.numberGrid["numberSquare"+thisSquare].coverLayer._alpha = 100; _root.numberGrid["numberSquare"+thisSquare].myColourNumber = 4; } } } } function clearRow(thisRow) { if(_root.selectColumnCover._alpha < 10) { rowFlagArray[thisRow] = 0; rowStartSquare = _root.startNumber+((thisRow -1)*_root.rowLength); for(thisSquare = rowStartSquare; thisSquare < (rowStartSquare + _root.rowLength); thisSquare++ ) { if(_root.coverFlag==1){ _root.numberGrid["numberSquare"+thisSquare].blueLayer._alpha = 100; _root.numberGrid["numberSquare"+thisSquare].blueText_mc._alpha = 0; _root.numberGrid["numberSquare"+thisSquare].myColourNumber = 0 } if(_root.coverFlag==2){ _root.numberGrid["numberSquare"+thisSquare].coverLayer._alpha = 0; _root.numberGrid["numberSquare"+thisSquare].myColourNumber = 0 } } } } function selectColumn(thisCol) { if(_root.selectColumnCover._alpha < 10) { colFlagArray[thisCol] = 1; colStartSquare = (thisCol + _root.startNumber - 1); for(thisSquare = colStartSquare; thisSquare <= _root.maxNumber; thisSquare = thisSquare + _root.rowLength ) { if(_root.coverFlag==1){ _root.numberGrid["numberSquare"+thisSquare].blueLayer._alpha = 0; _root.numberGrid["numberSquare"+thisSquare].blueText_mc._alpha = 100; _root.numberGrid["numberSquare"+thisSquare].myColourNumber = 1 } if(_root.coverFlag==2){ _root.numberGrid["numberSquare"+thisSquare].coverLayer._alpha = 100; _root.numberGrid["numberSquare"+thisSquare].myColourNumber = 4 } } } } function clearColumn(thisCol) { if(_root.selectColumnCover._alpha < 10) { colFlagArray[thisCol] = 0; colStartSquare = (thisCol + _root.startNumber - 1); for(thisSquare = colStartSquare; thisSquare <= _root.maxNumber; thisSquare = thisSquare + _root.rowLength) { if(_root.coverFlag==1){ _root.numberGrid["numberSquare"+thisSquare].blueLayer._alpha = 100; _root.numberGrid["numberSquare"+thisSquare].blueText_mc._alpha = 0; } if(_root.coverFlag==2){ _root.numberGrid["numberSquare"+thisSquare].coverLayer._alpha = 0; } } } } function colourPrimes() { _root.factorsNumber = _root.factorsNumber + 1; for(nextPrimePlace = 1; nextPrimePlace <= 32; nextPrimePlace = nextPrimePlace + 1) { nextPrime = _root.primesArray[nextPrimePlace]; if(_root.factorsNumber ==1) { _root.numberGrid["numberSquare"+nextPrime].blueLayer._alpha = 0; _root.numberGrid["numberSquare"+nextPrime].blueText_mc._alpha = 100; } if(_root.factorsNumber ==2) { if(_root.numberGrid["numberSquare"+nextPrime].blueLayer._alpha < 10) { _root.numberGrid["numberSquare"+nextPrime].redLayer._alpha = 30; _root.numberGrid["numberSquare"+nextPrime].blueText_mc._alpha = 100; } else { _root.numberGrid["numberSquare"+nextPrime].blueLayer._alpha = 0; _root.numberGrid["numberSquare"+nextPrime].redLayer._alpha = 0 _root.numberGrid["numberSquare"+nextPrime].blueText_mc._alpha = 0 } } if (_root.factorsNumber >=3) { if(_root.numberGrid["numberSquare"+nextPrime].redLayer._alpha < 50) { _root.numberGrid["numberSquare"+nextPrime].greenLayer._alpha =30; _root.numberGrid["numberSquare"+nextFactor].blueText_mc._alpha = 100 } else { _root.numberGrid["numberSquare"+nextPrime].blueLayer._alpha = 0; _root.numberGrid["numberSquare"+nextPrime].redLayer._alpha = 0; _root.numberGrid["numberSquare"+nextPrime].greenLayer._alpha = 0 } } } } gotoAndStop (20);