1 Reply Latest reply on May 17, 2010 4:58 PM by studentofflash11

    reflecting text...

    studentofflash11

      In my program i have a two small "planet" following an eliptical guide. Within these two planets i want to put text. The actual program itself allows the user to flip the "screen" and zoom in and i want the text to sit between those two paths and if the user flips it be able to see it correctly.

       

      Here is the code:

      onClipEvent (load) {

       

          function path(t1, t2){
              return Math.sqrt(t1 * t1 + t2 * t2);
          }

       

          function label(){
              showLabel = !showLabel;
              if(showLabel) for(k = 0; k < count; k++) this[k].info = n[k];
              else for(k = 0; k < count; k++) this[k].info = "";
          }

       

          c1 = new Array();        // endpoints coordinates of each ellipse conjugate diameters
          c2 = new Array();
          c3 = new Array();

       

          this.drag._x = 800;        // set zoom
          this.drag._y = -100;    // set elevation
          var showLabel = false;

       

          // Planetary Orbital Elements (J2000)
          J2000 = new Date(2000, 0, 0, 12);
          n = new Array('Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune');
          a = new Array(0.38709893, 0.72333199, 1.00000011, 1.52366231, 5.20336301, 9.53707032, 19.19126393, 30.06896348);
          e = new Array(0.20563069, 0.00677323, 0.01671022, 0.09341233, 0.04839266, 0.05415060, 0.04716771, 0.00858587);
          i = new Array(7.00487, 3.39471, 0.00005, 1.85061, 1.30530, 2.48446, 0.76986, 1.76917);
          o = new Array(48.33167, 76.68069, -11.26064, 49.57854, 100.55615, 113.71504, 74.22988, 131.72169);
          w = new Array(77.45645, 131.53298, 102.94719, 336.04084, 14.75385, 92.43194, 170.96424);
          l = new Array(252.25084, 181.97973, 100.46435, 355.45332, 34.40438, 49.94432, 313.23218);
          p = new Array(87.969, 224.701, 365.256, 686.980, 4332.589, 10759.22, 30685.4, 60189);
          cr = Math.PI/180;
          today = new Date();
          dt = (today - J2000)/864e+5;
          count = n.length;
          inc = 1;
          var pre = null;    // drag motion detect
          zoom = 8;
          d = new Array();
          B = new Array();
          co = new Array();
          so = new Array();
          ci = new Array();
          si = new Array();
          for (j = 0; j < count; j++) {
              d[j] = 2 * Math.PI / p[j];
              co[j] = Math.cos(o[j] * cr);
              so[j] = Math.sin(o[j] * cr);
              ci[j] = Math.cos(i[j] * cr);
              si[j] = Math.sin(i[j] * cr);
              u[j] = (w[j] + l[j]) * cr;
              b[j] = Math.sqrt( (1 + e[j]) / (1 - e[j]) );

       

              c1[j] = traf(0);
              c2[j] = traf(Math.PI / 2);
              c3[j] = traf(3 * Math.PI / 2);

       

              this.attachMovie("ellipse", count + j, j);
              this.attachMovie("dot", j, j + count);
              if(j > 8) this[j]._alpha = this[count + j]._alpha = 50;
          }

       

          function traf(e1){
              vector = new Object();
              var v = 2 * Math.atan( b[j] * Math.tan(e1/2) ) + u[j];
              var r = a[j] * ( 1 - e[j] * Math.cos(e1) );
              vector.x = r * ( co[j] * Math.cos(v) - so[j] * ci[j] * Math.sin(v) );
              vector.y = r * ( so[j] * Math.cos(v) + co[j] * ci[j] * Math.sin(v) );
              vector.z = r * si[j] * Math.sin(v);
              return vector;
          }

       

          function place(pass){
              cmx = Math.cos(mx);
              smx = Math.sin(mx);
              zoom = 5 + drag._x/20;
              if (zoom < 1) zoom = 1;
              if (zoom > 120) zoom = 120;
              this.sun._xscale = this.sun._yscale = zoom;
              xk = zoom * pass.x;
              yk = zoom * (pass.z * smx - pass.y * cmx);
              this[j]._x = xk;
              this[j]._y = yk;

       

              if(pre != drag._y * drag._x){                        // if zoomed or turned transform ellipses
                  x1 = zoom * c1[j].x;
                  y1 = zoom * (c1[j].z * smx - c1[j].y * cmx);
                  x2 = zoom * c2[j].x;
                  y2 = zoom * (c2[j].z * smx - c2[j].y * cmx);
                  x3 = zoom * c3[j].x;
                  y3 = zoom * (c3[j].z * smx - c3[j].y * cmx);
                  ax = (x2 + x3 + y3 - y2)/2 - x1;
                  ay = (x2 - x3 + y2 + y3)/2 - y1;
                  bx = (x2 + x3 + y2 - y3)/2 - x1;
                  by = (x3 - x2 + y2 + y3)/2 - y1;
                  xc = (x2 + x3)/2;
                  yc = (y2 + y3)/2;
                  ek = path(bx, by) / path(ax, ay);
                  ex = bx + ek * ax;
                  ey = by + ek * ay;
                  es = path(ex, ey);
                  et = ( ay * (xc - x1) - ax * (yc - y1) ) / (ax * ex + ay * ey);
                  xm = xc - x1 - ey * et;
                  ym = yc - y1 + ex * et;
                  xa = ax - xm;
                  ya = ay - ym;
                  sa = path(xm, ym);
                  with(this[count + j]){
                      _x = xc - sa * ex / es;
                      _y = yc - sa * ey / es;
                      _xscale = sa;
                      _yscale = path(xa, ya);
                      _alpha = 25 + 100 * _yscale / _xscale;
                      _rotation = 180 * Math.atan2(-ey, -ex) / Math.PI;
                  }
              }
          }

       

          function kepler(){
              for(j = 0; j < count; j++){
                  m = dt * d[j];
                  e0 = m + e[j] * Math.sin(m);
                  e0 = m + e[j] * Math.sin(e0);
                  place( traf(e0) );
              }
          }
      }

       

      onClipEvent (enterFrame) {
          mx = this.drag._y * cr / 2;
          kepler();
          pre = this.drag._y * this.drag._x;
          dt += inc;
      }

       

      Im not really sure how to do this at all so any help would be much appreciated.