用FlashAS实现画图的周详讲解(5)

2008-04-02 11:06:20来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折



  // 通过心脏线的方程定义起点的y坐标

  c = daxiao*(2*Math.cos((n 1)*Math.PI/180)

   Math.cos(2*((1 n)*Math.PI/180)));

  d = daxiao*(2*Math.sin((n 1)*Math.PI/180)

   Math.sin(2*((1 n)*Math.PI/180)));

  // 同理定义终点的经x,y坐标

  createEmptyMovieClip("yuan", n);

  // 创建一个空影片yuan

  with (yuan) {

  lineStyle(0.5, 0x000000, 100);

  // 定义线的大小、颜色、透明度

  moveTo(a 200, b 150);

  lineTo(c 200, d 150);

  // 从起点到终点画一条线,并把图像的中央点定为(200,150)

  }

  if (n<=360) {

  n = n 1;

  }

  };

  

  画螺旋线

  代码:
_root.onEnterFrame = function() {

  a = (10 0.1*n)*Math.cos(n*Math.PI/180);

  b = (10 0.1*n)*Math.sin(n*Math.PI/180);

  c = (10 0.1*n)*Math.cos((n 1)*Math.PI/180);

  d = (10 0.1*n)*Math.sin((n 1)*Math.PI/180);

  createEmptyMovieClip("yuan", n);

  with (yuan) {

  lineStyle(2, 0x000000, 50);

  moveTo(a 200, b 150);

  lineTo(c 200, d 150);

  }

  if (n<=900) {

  n = n 1;

  }

  };

  


  旋转的长方体

  代码:
a = 50*Math.cos(n*Math.PI/180);

  b = 100*Math.sin(n*Math.PI/180);

  c1 = 300;

  c2 = 200;

  _root.createEmptyMovieClip("triangle", 1);

  with (_root.triangle) {

  lineStyle(1, 0x000000, 50);

  moveTo(a c1, b c2);

  lineTo(50*math.cos((n 90)*math.pi/180)

  c1,100*math.sin((n 90)*math.pi/180) c2);

  lineTo(50*math.cos((n 180)*math.pi/180)

  c1,100*math.sin((n 180)*math.pi/180) c2);

  lineTo(50*math.cos((n 270)*math.pi/180)

  c1,100*math.sin((n 270)*math.pi/180) c2);

  lineTo(50*math.cos((n 360)*math.pi/180)

  c1,100*math.sin((n 360)*math.pi/180) 200);

  lineStyle(1, 0x000000, 50);

  moveTo(a 200, b 100);

  lineTo(50*math.cos((n 90)*math.pi/180)

  200,100*math.sin((n 90)*math.pi/180) 100);

  lineTo(50*math.cos((n 180)*math.pi/180)

  200,100*math.sin((n 180)*math.pi/180) 100);

  lineTo(50*math.cos((n 270)*math.pi/180)

  200,100*math.sin((n 270)*math.pi/180) 100);

  lineTo(50*math.cos((n 360)*math.pi/180)

  200,100*math.sin((n 360)*math.pi/180) 100);

  lineStyle(1, 0x000000, 30);

  moveTo(a 200, b 100);

  lineTo(a c1, b c2);

  moveTo(50*math.cos((n 90)*math.pi/180)

   c1,100*math.sin((n 90)*math.pi/180) c2);

  lineTo(50*math.cos((n 90)*math.pi/180)

   200,100*math.sin((n 90)*math.pi/180) 100);

  moveTo(50*math.cos((n 180)*math.pi/180)

   c1,100*math.sin((n 180)*math.pi/180) c2);

  lineTo(50*math.cos((n 180)*math.pi/180)

   200,100*math.sin((n 180)*math.pi/180) 100);

  moveTo(50*math.cos((n 270)*math.pi/180)

   c1,100*math.sin((n 270)*math.pi/180) c2);

  lineTo(50*math.cos((n 270)*math.pi/180)

   200,100*math.sin((n 270)*math.pi/180) 100);

  }


  用as做烛光,相当逼真。

  代码:
offsetX = 275;

  offsetY = 100;

  left = 0;

  right = 0;

  top = 0;

  leftGoal = 0;

  rightGoal = 0;

  topGoal = 0;

  rate = .2;

  decay = .9;

  for (var i = 0; i<shapes.length; i ) {

  var name = "flame" i;

  createEmptyMovieClip(name, i);

  _root[name]._x = offsetX;

  _root[name]._y = offsetY;

  _root[name].offset = parseInt(shapes[i].split("|")[0]);

  _root[name].fade = parseInt(shapes[i].split("|")[1]);

  }

  createEmptyMovieClip("heat", i);

  heat._x = offsetX;

  heat._y = offsetY;

  checkEdge = function (cur, side, dist) {

  change = 0;if (cur>side) {

  change -= Math.random()*dist;

  } else if (cur<-side) {

  change = Math.random()*dist;

  }

  return change;

  };

  onEnterFrame = function () {

  leftGoal = Math.random()*6-3;

  leftGoal = checkEdge(leftGoal,10, 3);

  rightGoal = Math.random()*6-3;

  rightGoal = checkEdge(rightGoal, 10,3);

  topGoal = Math.random()*8-4;

  topGoal = checkEdge(topGoal, 15, 4);

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇: Flash使用技巧-用Flash制作转动的地球仪

下一篇: 新浪/闪客帝国图片效果解析