“三生”为你分享9篇“Flash教程:制作无限回廊效果”,经本站小编整理后发布,但愿对你的工作、学习、生活带来方便。

篇1:Flash教程:制作无限回廊效果
准备6个100 × 100的图片
1、新建Flash 文件,设置属性: 500 × 200 ,背景黑色,
2、从菜单选择文件-> 导入-> 导入到舞台。选择你要使用的图片。图1:
3、垂直地对舞台的中心放置图片。平均、水平地隔开他们。使用对齐面板。图2、图3: 4、将图片转换成影片剪辑:单击舞台上最左边的图片转换成影片剪辑。命名为”My Image 1 ″而且设定注册点为居左中位置。
5、重复这个步骤,将其它的图片全部转换为影片剪辑。命名为 “ My Image 2 ″ ”,My Image 3 ″ ... 依此类推。图4:
现在你的库如图5: 6、双击”My Image 1″影片剪辑,进入My Image 1的编辑状态,添加 as图层。图6: 选中第1帧,在动作面板中输入代码:
//Import TweenMax
import gs.*;
//Set the initial state for this movie clip
TweenMax.to(this, 0.5, {alpha: 0.4});
//Add mouse over & out event listeners
this.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
this.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
//This function is called when mouse is over this movie clip
function mouseOverHandler(e:Event):void {
//Tween the alpha
TweenMax.to(this, 0.5, {alpha: 1});
}
//This function is called when mouse is out of this movie clip
function mouseOutHandler(e:Event):void {
//Tween the alpha
TweenMax.to(this, 0.5, {alpha: 0.4});
}
重复这个步骤到其它的影片剪辑。(当移动鼠标在一个图片上的时候,添加一个透明度效果。可以修改成放大或其它效果,自行的试验一下。)
7、前期工作已全部完成,现在开始创建无限循环,
在主时间轴,选择所有的六个影片剪辑。将他们转换成影片剪辑,命名 “ Gallery Images ”。图7:
8、为了使图片有无限循环的效果,我们需要舞台上的 “ Gallery Images ” 影片剪辑的另一个实例。因此在舞台上复制(选中Gallery Images,按住Ctrl键拖拽)另外的一个 “ Gallery Images ” 影片剪辑,放置在第一个实例后面,使他们水平地排列。图8: 9、选中舞台上的 “ Gallery Images ” 影片剪辑的两个实例。将他们转换成影片剪辑,命名 “ Infinite Gallery ” 设定注册点为左居中。图9: 10、在属性面板填入实例名字 “ infiniteGallery” 。
11、添加as层,打开动作面板输入代码:
//Import TweenMax
import gs.*;
//Save the horizontal center
var centerX:Number = stage.stageWidth / 2;
//Save the width of the whole gallery
var galleryWidth:Number = infiniteGallery.width;
//Speed of the movement (calculated by the mouse position in the moveGallery function)
var speed:Number = 0;
//Add an ENTER_FRAME. listener for the animation
addEventListener(Event.ENTER_FRAME, moveGallery);
function moveGallery(e:Event):void {
//Calculate the new speed
speed = -(0.05 * (mouseX - centerX));
//Update the x coordinate
infiniteGallery.x+=speed;
//Check if we are too far on the right (no more stuff on the left edge)
if (infiniteGallery.x>0) {
//Update the gallery’s coordinates
infiniteGallery.x= (-galleryWidth/2);
}
//Check if we are too far on the left (no more stuff on the right edge)
if (infiniteGallery.x<(-galleryWidth/2)) {
//Update the gallery’s coordinates
infiniteGallery.x=0;
}
}
这一段代码负责无限循环。
12、全部完工,测试影片。
更多内容进入:
精品学习网IT教育频道
篇2:Flash制作制作无限级菜单
菜单
原来是三级菜单,写书时想把它做为例子(第5章的第4个例子中),于是用递归改成无限级的
首先得准备xml文件
部分载图:
核心代码:
function addMenu(mc) {
removeMenu((mc.level-1)*depthDis, (mc.level+menuLevel-1)*depthDis-1);
var tempArray = [];
tempArray = mc.data;
var j = tempArray.length;
for (var i = 0; i
var d = mc.level*depthDis-i-1;
var t = menu.duplicateMovieClip(“menu”+d, d);
menuStyle(t, tempArray[i].attributes.text);
t._x = mc._x+(mc._width+dis);
t._y = mc._y+(hei+dis)*i;
if (tempArray[i].childNodes[0] != undefined) {
var tmc = t.createEmptyMovieClip(“nex”, 2);
createNext(tmc, wid-12, 5);
}
t.data = tempArray[i].childNodes;
t.level = mc.level+1;
t.id = i;
t.onRollOver = function() {
addMenu(this);
mc.prev = mc.curr;
menuOutStyle(mc.prev);
mc.curr = this;
menuRollStyle(mc.curr);
};
if (t.data[0] == undefined) {
t.onRelease = function() {
var _u = tempArray[this.id].attributes.link;
if (_u != undefined) {
createLoading(“swf/”+_u);
}
};
}
}
}
呵,用了Tween类,效果很cool
篇3:Flash教程:纯AS代码制作的燃烧的火焰效果
背景
var mcs:MovieClip = createEmptyMovieClip(“query”, -1);
with (mcs) {
beginFill(0x000000,100);
lineStyle(0,0x000000,0);
moveTo(0,0);
lineTo(Stage.width,0);
lineTo(Stage.width,Stage.height);
lineTo(0,Stage.height);
lineTo(0,0);
endFill;
}
制作影片剪辑实例
import flash.geom.*;
var McR:Number = 40;
var McA:Number = 60;
var CreaMovie:MovieClip = this.createEmptyMovieClip(“CreaMc”, 0);
with (CreaMovie) {
fillType = “radial”;
colors = [0xFFFF00, 0xFFFF00];
alphas = [McA, 0];
ratios = [0, 0xFF];
matrix = new Matrix();
matrix.createGradientBox(McR,McR,0,0,0);
beginGradientFill(fillType,colors,alphas,ratios,matrix);
moveTo(0,0);
lineTo(0,McR);
lineTo(McR,McR);
lineTo(McR,0);
lineTo(0,0);
endFill();
}
CreaMovie._visible = false;
火效果
var McNum:Number = 1;
var McMore:Number = 200;
var McRandom:Number = 6;
var McY:Number = 4;
var Mc_x:Number = Stage.width/2;
var Mc_y:Number = Stage.height/2+Stage.height/4;
var Mc_more:Number = 100;
var Mc_scal:Number = 50;
flame = function(){;
var scale:Number=random(Mc_scal)+1;
var flames:MovieClip=CreaMovie.duplicateMovieClip(“flames”+McNum,McNum,{_x:Mc_x,_y:Mc_y,_alpha:Mc_more/2,_xscale:scale,_yscale:scale});
flames.blendMode = “add”;
flames.fast=Math.floor(scale/10);
flames.action=(random(2)==1)?1:-1;
flames.scal=10-flames.fast;
flames.n=flames.s=1;
flames._r = flames._g = 255;
flames._b =0;
flames.gs=(10-flames.scal+2)*3;
flames.onEnterFrame=function(){
this._x+=this.fast*this.action*this.n*this.s;
this._y-=McY;
this._xscale+=this.scal*this.n*this.s;
this._yscale+=this.scal*this.n*this.s;
this._alpha+=10*this.n*this.s;
this._g-=this.gs;
if(this._g<=0){
this._g=0;
}
new Color(this).setRGB(this._r << 16 | this._g << 8 | this._b);
if(this._xscale>=Mc_more){;
this.n=-1;
this.s=0.2;
};
if(this._alpha>=Mc_more){;
this._alpha=Mc_more;
}else if(this._alpha<=random(20)){;
this.removeMovieClip();
delete this.onEnterFrame();
};
};
if(McNum>=McMore){;
McNum=0;
};
McNum++;
};
setInterval(flame,10);
篇4:Flash AS教程:制作物理课件电流效果
在学习中遇到问题可以到 论坛 发贴交流!
先来看效果: