Flash AS实现颜色渐变光线旋转特效_Flash教程
教程Tag:暂无Tag,欢迎添加,赚取U币!
推荐:Flash联合粒子特效软件打造超酷浪漫动画特效看到闪吧某网友在学习这个的过程中碰到一些问题,就帮解答一下。在此写写教程,有不足之处,还请大家指点。粒子特效软件的功能还很多,有爱好的可以自行研究下
旋转特效效果
代码如下:
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中按钮控制小球左右滚动的两种写法[前言]高手莫看,给初学者。[步骤]第一步:创建影片剪辑元件,画个小球,拖到主场景中,实例名为_mc第二步:创建按钮元件,画一个按钮,拖到主场景中,实例
相关Flash教程:
- 相关链接:
- 教程说明:
Flash教程-Flash AS实现颜色渐变光线旋转特效。