万卷书   首页 > 电脑书籍 > Flash > Flash鼠标特效精选实例(1)
 

  5.新建一影片剪辑“animation”,将默认图层命名为“animation”,“ animation”只有一个图层,同时只有四帧。下面将分别为这四个关键帧进行相应设置
选中第1关键帧,添加如下ActionScript脚本代码:

// creazione della classe PuntoSpaziale
function PuntoSpaziale (x, y, z, target) {
// propriet?
this.target = target;
this.x = x;
this.y = y;
this.z = z;
this.firstx = x;
this.firsty = y;
this.firstz = z;
this.DFOWA = 100;
// Distance From Object World Axes
this.DFPP = 200;
// Distance From Proiection Plain
this.ScreenCenter_x = 300;
this.ScreenCenter_y = 200;
this.speed2dx = 0;
this.speed2dy = 0;
// metodi
this.Coord2DRelativeTo = Coord2DRelativeTo;
this.Coord3DRelativeTo = Coord3DRelativeTo;
this.Rotate = Rotate;
this.Scale = Scale;
this.UScale = UScale;
this.Traslate = Traslate;
this.Proiection_y = Proiection_y;
this.Proiection_x = Proiection_x;
this.DrawPoint = DrawPoint;
// funzioni che definiscono i metodi
function Coord3DRelativeTo (x1, y1, z1) {
// cambio di coordinate 3D in riferimento ad un'altro punto
this.x -= x1;
this.y -= y2;
this.z -= z3;
}
function Coord2DRelativeTo (x, y) {
// cambio di coordinate "D di proiezione in riferimento ad un'altro punto
// per esempio si pu?usare per centrare il punto (0,0) al centro dello schermo
// ( in tal caso passare come parametri le coordinate di tale centro )
this.ScreenCenter_x = x;
this.ScreenCenter_y = y;
}
function Rotate (teta_x, teta_y, teta_z) {
// rotazione intorno agli assi x, y e z espressa in radianti
if (teta_x != 0) {
ytemp = this.y;
this.y = this.y*Math.cos(teta_x)-this.z*Math.sin(teta_x);
this.z = ytemp*Math.sin(teta_x)+this.z*Math.cos(teta_x);
}
if (teta_y != 0) {
xtemp = this.x;
this.x = this.x*Math.cos(teta_y)+this.z*Math.sin(teta_y);
this.z = this.z*Math.cos(teta_y)-xtemp*Math.sin(teta_y);
}
if (teta_z != 0) {
xtemp = this.x;
this.x = this.x*Math.cos(teta_z)-this.y*Math.sin(teta_z);
this.y = this.y*Math.cos(teta_z)+xtemp*Math.sin(teta_z);
}
}
function Scale (sx, sy, sz) {
// scalamento non uniforme
this.x *= sx;
this.y *= sy;
this.z *= sx;
}
function UScale (s) {
// scalamento uniforme
this.x *= s;
this.y *= s;
this.z *= s;
}
function Traslate (a, b, c) {
// traslazione
this.x += a;
this.y += b;
this.z += c;
}

上一页 下一页