教你用FLASH制作漂亮的图形旋转动画效果_Flash教程-查字典教程网
教你用FLASH制作漂亮的图形旋转动画效果
教你用FLASH制作漂亮的图形旋转动画效果
发布时间:2016-12-21 来源:查字典编辑
摘要:本教程是向大家介绍利用FLASH制作漂亮的图形旋转动画效果,采用代码实现特效,对于编程人员非常适合学习,转发过来,希望大家喜欢!效果:代码如...

本教程是向大家介绍利用FLASH制作漂亮的图形旋转动画效果,采用代码实现特效,对于编程人员非常适合学习,转发过来,希望大家喜欢!

效果:

代码如下:

复制代码代码如下:var pMaxSize:Number = 150;

var pCenterX:Number = 275;

var pCenterY:Number = 200;

var pNumTraces:Number = 20;

var pNumLayers:Number = 30;

var pCurrentLayer:Number = 0;

var pLineColour:Number;

var pPointDegree:Array = new Array();

var pPointDegreeChange:Array = new Array();

var pPointScale:Array = new Array();

var pPointScaleChange:Array = new Array();

var pPointX:Array = new Array();

var pPointY:Array = new Array();

var pBaseTimeline:MovieClip;

var pIntervalId:Number;

function init(baseTimeline:MovieClip):Void {

pBaseTimeline = baseTimeline;

pBaseTimeline.createEmptyMovieClip("holder", 0);

for (var j:Number = 0; j<pNumLayers; j++) {

pBaseTimeline.createEmptyMovieClip("layer"+j, j+1);

pBaseTimeline["layer"+j]._x = pCenterX;

pBaseTimeline["layer"+j]._y = pCenterY;

}

initTraces();

pBaseTimeline.holder.onEnterFrame = function() {

moveSpheres();

};

pIntervalId = setInterval(this, "updateSeeds", 2000);

}

function initTraces() {

for (var i:Number = 0; i<pNumTraces; i++) {

pPointX = 0;

pPointY = 0;

pPointDegree = (6.28318530718/pNumTraces)*i;

pPointScale = 50;

}

updateSeeds();

for (i=0; i<pNumTraces; i++) {

plotLine(i);

}

}

function moveSpheres() {

for (var i:Number = 0; i<pNumTraces; i++) {

pPointDegree += pPointDegreeChange;

pPointScale += pPointScaleChange;

plotLine(i, true);

}

pBaseTimeline["layer"+pCurrentLayer]._alpha = 100;

pCurrentLayer = (pCurrentLayer+1)%pNumLayers;

for (var j:Number = 0; j<pNumLayers; j++) {

pBaseTimeline["layer"+((pCurrentLayer+j)%pNumLayers)]._alpha = (j/pNumLayers)*100;

}

pBaseTimeline["layer"+pCurrentLayer].clear();

}

function plotLine(i:Number, drawLine:Boolean) {

pBaseTimeline["layer"+pCurrentLayer].lineStyle(1, pLineColour, 100);

pBaseTimeline["layer"+pCurrentLayer].moveTo(pPointX, pPointY);

pPointX = (Math.cos(pPointDegree)*pPointScale);

pPointY = (Math.sin(pPointDegree)*pPointScale);

if (drawLine == true) {

pBaseTimeline["layer"+pCurrentLayer].lineTo(pPointX, pPointY);

}

}

function updateSeeds() {

var deg:Number;

var scale:Number;

deg = randomRange(-100, 100)/2000;

if (pPointScale[0]>pMaxSize) {

scale = randomRange(-10, 0)/2;

} else if (pPointScale[0]<-pMaxSize) {

scale = randomRange(0, 10)/2;

} else {

scale = randomRange(-10, 10)/2;

}

for (var i:Number = 0; i<pNumTraces; i++) {

pPointDegreeChange = deg;

pPointScaleChange = scale;

}

pLineColour = randomRange(0, 0xFFFFFF);

}

function randomRange(min:Number, max:Number):Number {

var randomNum:Number = Math.round(Math.random()*(max-min))+min;

return randomNum;

}

init(this);

教程结束,以上就是FLASH制作漂亮的图形旋转动画效果,希望大家喜欢本教程!

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新Flash教程学习
    热门Flash教程学习
    网页设计子分类