用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);
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制作漂亮的图形旋转动画效果,希望大家喜欢本教程!
本文地址:http://www.45fan.com/bcdm/9828.html