class rubik { //arrays where to store the cubes that make up each face. public var F1, F2, F3, F4, F5, F6:Array; public var c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27:cub; //cea mai mare si tampita functie constructor public function rubik() { F1 = new Array();F2 = new Array();F3 = new Array();F4 = new Array();F5 = new Array();F6 = new Array(); var a = -137.5; // center offset var r = 75; //radius c1 = new cub(0+a, 0+a, 0+a, r, _root.funk); c2 = new cub(0+a, 0+a, 100+a, r, _root.funk); c3 = new cub(0+a, 0+a, 200+a, r, _root.funk); c4 = new cub(100+a, 0+a, 0+a, r, _root.funk); c5 = new cub(100+a, 0+a, 100+a, r, _root.funk); c6 = new cub(100+a, 0+a, 200+a, r, _root.funk); c7 = new cub(200+a, 0+a, 0+a, r, _root.funk); c8 = new cub(200+a, 0+a, 100+a, r, _root.funk); c9 = new cub(200+a, 0+a, 200+a, r, _root.funk); c10 = new cub(0+a, 100+a, 0+a, r, _root.funk); c11 = new cub(0+a, 100+a, 100+a, r, _root.funk); c12 = new cub(0+a, 100+a, 200+a, r, _root.funk); c13 = new cub(100+a, 100+a, 0+a, r, _root.funk); c14 = new cub(100+a, 100+a, 100+a, r, _root.funk); c15 = new cub(100+a, 100+a, 200+a, r, _root.funk); c16 = new cub(200+a, 100+a, 0+a, r, _root.funk); c17 = new cub(200+a, 100+a, 100+a, r, _root.funk); c18 = new cub(200+a, 100+a, 200+a, r, _root.funk); c19 = new cub(0+a, 200+a, 0+a, r, _root.funk); c20 = new cub(0+a, 200+a, 100+a, r, _root.funk); c21 = new cub(0+a, 200+a, 200+a, r, _root.funk); c22 = new cub(100+a, 200+a, 0+a, r, _root.funk); c23 = new cub(100+a, 200+a, 100+a, r, _root.funk); c24 = new cub(100+a, 200+a, 200+a, r, _root.funk); c25 = new cub(200+a, 200+a, 0+a, r, _root.funk); c26 = new cub(200+a, 200+a, 100+a, r, _root.funk); c27 = new cub(200+a, 200+a, 200+a, r, _root.funk); for (var i = 1; i<=27; i++) { if(i!=14) _root.scene1.adaugaObiect(this["c"+i]); } //asignarea culorilor for(i = 19; i<= 27; i++) { this["c"+i].l3.style = _root.rosu; this["c"+i].l3.defStyle = _root.rosu; } for(i=3;i<=27;i+=3) { this["c"+i].l2.style = _root.verde; this["c"+i].l2.defStyle = _root.verde; } for(i=1;i<=9;i++) { this["c"+i].l6.style = _root.albastru; this["c"+i].l6.defStyle = _root.albastru; } for(i=1;i<=25;i+=3) { this["c"+i].l1.style = _root.negru; this["c"+i].l1.defStyle = _root.negru; } //asignarea cuburilor fetelor. F1.push(c27); F1.push(c24); F1.push(c21); F1.push(c26); F1.push(c23); F1.push(c20); F1.push(c25); F1.push(c22); F1.push(c19); // F2.push(c27); F2.push(c24); F2.push(c21); F2.push(c18); F2.push(c15); F2.push(c12); F2.push(c9); F2.push(c6); F2.push(c3); // F3.push(c9); F3.push(c6); F3.push(c3); F3.push(c8); F3.push(c5); F3.push(c2); F3.push(c7); F3.push(c4); F3.push(c1); // F4.push(c19); F4.push(c22); F4.push(c25); F4.push(c10); F4.push(c13); F4.push(c16); F4.push(c1); F4.push(c4); F4.push(c7); // c7.l5.style = _root.galben; c7.l5.defStyle = _root.galben; F5.push(c25); c8.l5.style = _root.galben; c8.l5.defStyle = _root.galben; F5.push(c26); c9.l5.style = _root.galben; c9.l5.defStyle = _root.galben; F5.push(c27); c16.l5.style = _root.galben; c16.l5.defStyle = _root.galben; F5.push(c16); c17.l5.style = _root.galben; c17.l5.defStyle = _root.galben; F5.push(c17); c18.l5.style = _root.galben; c18.l5.defStyle = _root.galben; F5.push(c18); c25.l5.style = _root.galben; c25.l5.defStyle = _root.galben; F5.push(c7); c26.l5.style = _root.galben; c26.l5.defStyle = _root.galben; F5.push(c8); c27.l5.style = _root.galben; c27.l5.defStyle = _root.galben; F5.push(c9); // c1.l4.style = _root.alb; c1.l4.defStyle = _root.alb; F6[0] = c21; c2.l4.style = _root.alb; c2.l4.defStyle = _root.alb; F6[1] = c20; c3.l4.style = _root.alb; c3.l4.defStyle = _root.alb; F6[2] = c19; c10.l4.style = _root.alb; c10.l4.defStyle = _root.alb; F6[3] = c12; c11.l4.style = _root.alb; c11.l4.defStyle = _root.alb; F6[4] = c11; c12.l4.style = _root.alb; c12.l4.defStyle = _root.alb; F6[5] = c10; c19.l4.style = _root.alb; c19.l4.defStyle = _root.alb; F6[6] = c3; c20.l4.style = _root.alb; c20.l4.defStyle = _root.alb; F6[7] = c2; c21.l4.style = _root.alb; c21.l4.defStyle = _root.alb; F6[8] = c1; //definirea supercuburilor c15.superCub = 2; c23.superCub = 1; c17.superCub = 5; c11.superCub = 6; c5.superCub = 3; c13.superCub = 4; } //function to call and set the interval for the aRotate function. public function FRotate(a:Number,sens:Number):Void { var t:point; //'t' reprezinta axa dupa care se va efectua rotatia t = new point(); if((a==3)||(a==1)) { t.x = 0; t.y = 1; t.z = 0; } if((a==4)||(a==2)) { t.x = 0; t.y = 0; t.z = 1; } if((a==5)||(a==6)) { t.x = 1; t.y = 0; t.z = 0; } _root.F = a; _root.supraRotate(this["F"+a],t,sens); //_root.instantRotate(this["F"+a],t); } public function iRotate(a:Number):Void { var t:point; //'t' reprezinta axa dupa care se va efectua rotatia t = new point(); if((a==3)||(a==1)) { t.x = 0; t.y = 1; t.z = 0; } if((a==4)||(a==2)) { t.x = 0; t.y = 0; t.z = 1; } if((a==5)||(a==6)) { t.x = 1; t.y = 0; t.z = 0; } _root.F = a; _root.instantRotate(this["F"+a],t); } public function adjustFaces(f:Number):Void { //"in-face" adjustments. trace("[F] " + f); var copy = new Array(); var len = this["F"+f].length; while(len--) { copy[len] = this["F"+f][len]; } switch (f) { case 1: this["F"+f][0] = copy[2]; this["F"+f][1] = copy[5]; this["F"+f][2] = copy[8]; this["F"+f][3] = copy[1]; this["F"+f][4] = copy[4]; this["F"+f][5] = copy[7]; this["F"+f][6] = copy[0]; this["F"+f][7] = copy[3]; this["F"+f][8] = copy[6]; ////////////////////////////////////////////////////////////////////// F2[0] = this["F"+f][0]; F2[1] = this["F"+f][1]; F2[2] = this["F"+f][2]; F4[0] = this["F"+f][8]; F4[1] = this["F"+f][7]; F4[2] = this["F"+f][6]; F5[0] = this["F"+f][6]; F5[1] = this["F"+f][3]; F5[2] = this["F"+f][0]; F6[0] = this["F"+f][2]; F6[1] = this["F"+f][5]; F6[2] = this["F"+f][8]; break; case 2: this["F"+f][0] = copy[6]; this["F"+f][1] = copy[3]; this["F"+f][2] = copy[0]; this["F"+f][3] = copy[7]; this["F"+f][4] = copy[4]; this["F"+f][5] = copy[1]; this["F"+f][6] = copy[8]; this["F"+f][7] = copy[5]; this["F"+f][8] = copy[2]; ////////////////////////////////////////////////////////////////////// F1[0] = this["F"+f][0]; F1[1] = this["F"+f][1]; F1[2] = this["F"+f][2]; F3[0] = this["F"+f][6]; F3[1] = this["F"+f][7]; F3[2] = this["F"+f][8]; F5[8] = this["F"+f][6]; F5[5] = this["F"+f][3]; F5[2] = this["F"+f][0]; F6[0] = this["F"+f][2]; F6[3] = this["F"+f][5]; F6[6] = this["F"+f][8]; break; case 3: this["F"+f][0] = copy[2]; this["F"+f][1] = copy[5]; this["F"+f][2] = copy[8]; this["F"+f][3] = copy[1]; this["F"+f][4] = copy[4]; this["F"+f][5] = copy[7]; this["F"+f][6] = copy[0]; this["F"+f][7] = copy[3]; this["F"+f][8] = copy[6]; ////////////////////////////////////////////////////////////////////// F2[6] = this["F"+f][0]; F2[7] = this["F"+f][1]; F2[8] = this["F"+f][2]; F4[8] = this["F"+f][6]; F4[7] = this["F"+f][7]; F4[6] = this["F"+f][8]; F5[6] = this["F"+f][6]; F5[7] = this["F"+f][3]; F5[8] = this["F"+f][0]; F6[6] = this["F"+f][2]; F6[7] = this["F"+f][5]; F6[8] = this["F"+f][8]; break; case 4: this["F"+f][0] = copy[2]; this["F"+f][1] = copy[5]; this["F"+f][2] = copy[8]; this["F"+f][3] = copy[1]; this["F"+f][4] = copy[4]; this["F"+f][5] = copy[7]; this["F"+f][6] = copy[0]; this["F"+f][7] = copy[3]; this["F"+f][8] = copy[6]; ////////////////////////////////////////////////////////////////////// F1[6] = this["F"+f][2]; F1[7] = this["F"+f][1]; F1[8] = this["F"+f][0]; F3[8] = this["F"+f][6]; F3[7] = this["F"+f][7]; F3[6] = this["F"+f][8]; F5[0] = this["F"+f][2]; F5[3] = this["F"+f][5]; F5[6] = this["F"+f][8]; F6[2] = this["F"+f][0]; F6[5] = this["F"+f][3]; F6[8] = this["F"+f][6]; break; case 5: this["F"+f][0] = copy[6]; this["F"+f][1] = copy[3]; this["F"+f][2] = copy[0]; this["F"+f][3] = copy[7]; this["F"+f][4] = copy[4]; this["F"+f][5] = copy[1]; this["F"+f][6] = copy[8]; this["F"+f][7] = copy[5]; this["F"+f][8] = copy[2]; ////////////////////////////////////////////////////////////////////// F1[6] = this["F"+f][0]; F1[3] = this["F"+f][1]; F1[0] = this["F"+f][2]; F3[0] = this["F"+f][8]; F3[3] = this["F"+f][7]; F3[6] = this["F"+f][6]; F4[2] = this["F"+f][0]; F4[5] = this["F"+f][3]; F4[8] = this["F"+f][6]; F2[0] = this["F"+f][2]; F2[3] = this["F"+f][5]; F2[6] = this["F"+f][8]; break; case 6: this["F"+f][0] = copy[2]; this["F"+f][1] = copy[5]; this["F"+f][2] = copy[8]; this["F"+f][3] = copy[1]; this["F"+f][4] = copy[4]; this["F"+f][5] = copy[7]; this["F"+f][6] = copy[0]; this["F"+f][7] = copy[3]; this["F"+f][8] = copy[6]; ////////////////////////////////////////////////////////////////////// F1[2] = this["F"+f][0]; F1[5] = this["F"+f][1]; F1[8] = this["F"+f][2]; F3[2] = this["F"+f][6]; F3[5] = this["F"+f][7]; F3[8] = this["F"+f][8]; F4[0] = this["F"+f][2]; F4[3] = this["F"+f][5]; F4[6] = this["F"+f][8]; F2[2] = this["F"+f][0]; F2[5] = this["F"+f][3]; F2[8] = this["F"+f][6]; break; default: trace("Face adjust error. Unkown face argument passed. It was [ " + f + " ] ."); break; } } } //sfarsit