最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
图片转场效果
时间:2022-07-02 17:15:56 编辑:袖梨 来源:一聚教程网
1. 注意共三张图片,一张是底版(pic_old)放在最底层,一张是切换来的新图(pic_new)放在中间层,最后还有一张用来做新图的遮罩层(mask);
2. 新图和底版的深度不要颠倒,新图要比底版的深度高,否则会发生错误;
3. 我们只在mask上面作文章,让mask去加载遮罩物,这样就可以完成许许多多不同的效果了。
步骤1:
(1) 绘制一个正方形(50*50),注册点在中心,保存为影片剪辑连接—>导出—>标志符 Rec;
(2) 绘制一个圆形(50*50),注册点在中心,保存为影片剪辑连接—>导出—>标志符 Cir;
(3) 导入图片n张,均保存为影片剪辑,注册点在左上(0,0)这些图片的连接—>导出—>标志符 分别从 pic1, pic2, pic3 ... ... picn
步骤2:
加入AS代码:
//临时变量用于存储当前图片
var n:Number = 0;
//变量n为当前所在图片
var Num:Number = 5;
//Num图片数量
//=======================================================
//鼠标点击后设置底版图、新图和遮罩层,并调用(PassEffect)
_root.onMouseDown = function() {
n = n < Num ? ++n : 1 ;
_root.createEmptyMovieClip("pic_old", -3);
pic_old.attachMovie(old_p, old_p, 1);
old_p = "pic"+n;
_root.createEmptyMovieClip("pic_new", -2);
pic_new.attachMovie("pic"+n, pic, 1);
_root.createEmptyMovieClip("mask", -1);
pic_new[pic].setMask(mask);
//在测试时,可以把setMask这句注释掉,可更好地观察遮罩层的情况
PassEffect();
};
//============================================================
function PassEffect() {
switch (1+Math.floor(Math.random()*7)) {
//***************效果1[见附录]***************
//复制若干个圆,分布在每行每列,并使每个圆的大小不断增加至覆盖整张图
case 1 :
for (i=0; i<7; i++) {
for (j=0; j<6; j++) {
var p:MovieClip = mask.attachMovie("Cir", "Cir"+i*10+j,
i*10+j);
//注意这里是mask.attachMovie(),加载来的图形都属于遮罩层(mask)
p._width = 20;
p._height = 20;
p._x = 20+i*60;
p._y = 20+j*60;
p.onEnterFrame = function() {
if (this._width<180) {
this._width = this._height += 8;
} else {
delete this.onEnterFrame;
}
};
}
}
break;
//=================================================================
//***************效果2[见附录]***************
case 2 :
var p:MovieClip = mask.attachMovie("Rec", Rec, 1);
p._width = 10;
p._height = 10;
p._x = Stage.width/2;
p._y = Stage.height/2;
p.onEnterFrame = function() {
if (this._width
this._width += 40;
this._height += 40;
} else {
delete this.onEnterFrame;
}
};
break;
//=================================================================
//***************效果3[见附录]****************
case 3 :
var p:MovieClip = mask.attachMovie("Rec", "Rec"+1, 1);
p._width = Stage.width+10;
p._height = Stage.height+10;
p._x = 0-p._width;
p._y = 0-p._height;
p.onEnterFrame = function() {
this._x += (Stage.width/2-this._x)*0.3;
this._y += (Stage.height/2-this._y)*0.3;
};
break;
//=================================================================
//***************效果4[见附录]***************
case 4 :
var p:MovieClip = mask.attachMovie("Rec", "Rec"+1, 1);
p._width = Stage.width;
p._height = Stage.height;
p._x = -p._width/2;
p._y = Stage.height/2;
p.onEnterFrame = function() {
if (this._x
this._x += 15;
} else {
delete this.onEnterFrame;
}
};
var p:MovieClip = mask.attachMovie("Rec", "Rec"+2, 2);
p._width = Stage.width;
p._height = Stage.height;
p._x = Stage.width+p._width/2;
p._y = Stage.height/2;
p.onEnterFrame = function() {
if (this._x>Stage.width/2) {
this._x -= 15;
} else {
delete this.onEnterFrame;
}
};
break;
//=================================================================
//***************效果5[见附录]***************
case 5 :
if (Math.random()<=0.5) {
var rotation = 45;
} else {
var rotation = -45;
}
for (i=-10, d_time=0; i<30; i++, d_time++) {
var p:MovieClip = mask.attachMovie("Rec", "Rec"+d_time, d_time);
p._width = 0;
p._height = Stage.height*2;
p._x = p._width/2+i*20;
p._y = Stage.height/2;
p._rotation = rotation;
p.delay = d_time;
p.start_time = 0;
p.onEnterFrame = function() {
if (this.start_time
this.start_time += 3;
} else if (this._xscale<30) {
this._xscale += 2;
} else {
delete this.onEnterFrame;
}
};
}
break;
//=================================================================
//***************效果6[见附录]***************
case 6 :
if (Math.random()<=0.5) {
for (i=0; i<45; i++) {
var p:MovieClip = mask.attachMovie("Rec", "Rec"+i, i);
p._width = 0;
p._height = Stage.height+10;
p._x = i*10;
p._y = Stage.height/2;
p.delay = i;
p.start_time = 0;
p.onEnterFrame = function() {
if (this.start_time
this.start_time += 3;
} else if (this._xscale<30) {
this._xscale += 2;
} else {
delete this.onEnterFrame;
}
};
}
} else {
for (i=0; i<35; i++) {
var p:MovieClip = mask.attachMovie("Rec", "Rec"+i, i);
p._width = Stage.width+10;
p._height = 0;
p._x = Stage.width/2;
p._y = i*10;
p.delay = i;
p.start_time = 0;
p.onEnterFrame = function() {
if (this.start_time
this.start_time += 3;
} else if (this._yscale<30) {
this._yscale += 2;
} else {
delete this.onEnterFrame;
}
};
}
}
break;
//=================================================================
//***************效果7[见附录]***************
case 7 :
for (i=0; i<40; i++) {
var p:MovieClip = mask.attachMovie("Rec", "Rec"+i, i);
p._width = 10;
p._height = Stage.height+50;
p._x = p._width/2+i*p._width;
p._y = -p._height+Math.random()*50;
p.onEnterFrame = function() {
if (this._y
this._y += 20;
} else {
delete this.onEnterFrame;
}
};
}
break;
}
}
Flash充电1: MovieClip.setMask 方法 mc.setMask(mask:Object): 使参数 mask 中的影片剪辑成为 mc 的遮罩层。
Flash充电2: 条件运算符(三目运算) ? :格式:expression1 ? expression2 : expression3
例如:
var x:Number = 5;
var y:Number = 10;
var z = (x < 6) ? x: y;
trace (z);
// returns 5
相关文章
- 炉石传说血DK卡组怎么样 炉石传说血DK卡组推荐介绍 11-05
- 咒术回战幻影夜行官网在哪里 咒术回战幻影夜行官网地址介绍 11-05
- 蚂蚁庄园今天答题答案2024年10月26日 11-05
- 以闪亮之名变装物语甜趣篇怎么玩 11-05
- 闪耀暖暖永夜禁锢怎么玩 11-05
- 闪耀暖暖永夜禁锢怎么玩 闪耀暖暖永夜禁锢活动介绍 11-05