flash cs制造幸运大抽奖gif动画特效教程

更新时间:15-11-07 21:32 热度:436
 

良久未来这了,刚好这两天没关系事,又做了一个抽奖的小东东玩玩,只供菜鸟们参照,老鸟们见笑了。

照向例上主要代码:

复制代码

代码如下所述:

stop();
/*
@sxl
@qq:285510591
@http://sxl001.129hb.com
@2009.12.20
*/
system.usecodepage =true;
// title_mc:题目 gong_mc:显露中奖 msg_mc:显露全部中奖和未中奖事情状况
title_mc.cacheasbitmap=true;
gong_mc.cacheasbitmap=true;
gong_mc.y=1000;
msg_mc.cacheasbitmap=true;
msg_mc.x=-1000;
// 下面所开列是声响效果数值
var mousw_over_sound:over=new over(),rect_up_sound:move=new move(),rect_down_soundown=new down(),_win:win=new win();
// gong_array:奖物品名称 balls:各个号头 hit_ball_array:已抽号头
var gong_array:array =[],balls:array =[],hit_ball_array:array =[],move_gong_mc:boolean=true,move_msg_mc:boolean;
// 以下是内里设置奖品
var data_str:string =”环保手提袋罗技电磁炉显露器移动硬盘掌上游戏机手机3g手机九阳豆浆机电动剃须刀雅顿香水数字照相机闪保存到磁盘离子电视消毒柜松下洗衣机电磁炉电饭煲电压力锅光波炉拌和机榨汁机电茶壶咖啡机半自动做饭做锅紫砂煲空调吸油烟子机使暖和器加湿器”;
gong_array =data_str.split(“”);
randomarray(gong_array);
/* 以下注解局部是从外部文本中导入奖品数值
var loadernum:urlloader = new urlloader();
configurelistenersnum(loadernum);
var urlnum:string =”data/奖品.txt”;
var requestnum:urlrequest=new urlrequest(urlnum);
loadernum.load(requestnum);
function configurelistenersnum(dispatcher:ieventdispatcher):void {
dispatcher.addeventlistener(event.complete, completehnum);
dispatcher.addeventlistener(ioerrorevent.io_error, ioerrorhandler);
}
function completehnum(event:event):void {
gong_array =event.target.data.split(“”);
randomarray(gong_array);
event.target.removeeventlistener(event.complete, completehnum);
event.target.removeeventlistener(event.complete, ioerrorhandler);
}
function ioerrorhandler(event:ioerrorevent):void {
dele_balls_seleabled();
chakan_mc.buttonmode =false;
chakan_mc.removeeventlistener(mouseevent.mouse_over ,onmouse_click);
chakan_mc.removeeventlistener(mouseevent.mouse_down ,onmouse_click);
chakan_mc.removeeventlistener(mouseevent.mouse_out ,onmouse_click);
gong_mc._txt.text=”请查缉数值”;
gong_mc.ball._txt.text=”-_-”;
gong_mc.addeventlistener(event.enter_frame,move_gong_mc_rect);
gong_mc.close_变态n.enabled=false;
gong_mc.close_变态n.removeeventlistener(mouseevent.mouse_down,oncloseshowgong);
event.target.removeeventlistener(event.complete, completehnum);
event.target.removeeventlistener(event.complete, ioerrorhandler);
}
*/
for (var i:uint =0; i<30; i++) {
this["ball" + i].cacheasbitmap=true;
this["ball" + i].gotoandstop(“one”);
balls.push(this["ball" + i]);
msg_mc["m" + i].ball_mc.gotoandstop(“one”);
if (i<9) {
this["ball"+i]._txt.text=”0″+uint(i+1);
msg_mc["m"+i].ball_mc._txt.text=”0″+uint(i+1);
} else {
this["ball"+i]._txt.text=”"+uint(i+1);
msg_mc["m"+i].ball_mc._txt.text=”"+uint(i+1);
}
msg_mc["m"+i].t.text=”等 待 抽 奖”;
this["ball"+i].i=i;
this["ball"+i].buttonmode =true;
this["ball"+i].mousechildren=false;
this["ball" + i].addeventlistener(mouseevent.mouse_over ,onmouse_click);
this["ball" + i].addeventlistener(mouseevent.mouse_down ,onmouse_click);
this["ball" + i].addeventlistener(mouseevent.mouse_out ,onmouse_click);
//……
}
chakan_mc.buttonmode =true;
chakan_mc.mousechildren=false;
chakan_mc.addeventlistener(mouseevent.mouse_over ,onmouse_click);
chakan_mc.addeventlistener(mouseevent.mouse_down ,onmouse_click);
chakan_mc.addeventlistener(mouseevent.mouse_out ,onmouse_click);
function onmouse_click(sxl:mouseevent) {
var target:movieclip =sxl.currenttarget as movieclip;
var target_name:string =target.name.substr(0,1);
switch (sxl.type) {
case “mouseover” :
mousw_over_sound.play();
switch (target_name) {
case “b” :
getbitmapfilter(target);
break;
case “c” :
settxtcolor(target.t,0xffffff);
break;
}
break;
case “mouseout” :
switch (target_name) {
case “b” :
target.filters =门里出身;
break;
case “c” :
settxtcolor(target.t,0xffff00);
break;
}
break;
case “mousedown” :
switch (target_name) {
case “b” :
dele_balls_seleabled();
target.removeeventlistener(mouseevent.click ,onmouse_click);
target.gotoandstop(“two”);
settxtcolor(target._txt);
var index:string =target.i;
hit_ball_array.push(target);
var str:uint =uint(target.name.substr(4));
if (str<9) {
gong_mc.ball._txt.text=”0″+uint(str+1);
} else {
gong_mc.ball._txt.text=”"+uint(str+1);
}

gong_mc._txt.text=gong_array[index];
gong_mc.addeventlistener(event.enter_frame,move_gong_mc_rect);
rect_up_sound.play();

msg_mc["m" + index].ball_mc.play();
msg_mc["m"+index].t.text=gong_array[index];
settxtcolor(msg_mc["m"+index].t,0xffff00);
settxtcolor(msg_mc["m" + index].ball_mc._txt);
break;
case “c” :
target.t.text=”移开中奖最后结果”;
if (math.abs(gong_mc.y-300)<10) {
move_gong_mc=false;
gong_mc.addeventlistener(event.enter_frame,move_gong_mc_rect);
}
move_msg_mc=!move_msg_mc;
msg_mc.addeventlistener(event.enter_frame,show_msg_mc);
rect_up_sound.play();
break;
}
break;
}
}
//
function show_msg_mc(sxl:event) {
if (move_msg_mc) {
var dis_up:number =(354-sxl.target.x)/5;
sxl.target.x+=dis_up;
if (math.abs(dis_up)<1) {
sxl.target.x=354;
sxl.target.removeeventlistener(event.enter_frame,show_msg_mc);
}
} else {
var dis_down:number =(1800-sxl.target.x)/5;
sxl.target.x+=dis_down;
if (math.abs(dis_down)<10) {
chakan_mc.t.text=”检查上奖最后结果”;
sxl.target.x=-1000;
sxl.target.removeeventlistener(event.enter_frame,show_msg_mc);
}
}
}
// 删去全部数码按键功能
function dele_balls_seleabled() {
for (var i:uint =0; i<balls.length; i++) {
var a:movieclip =balls;
a.buttonmode =false;
a.removeeventlistener(mouseevent.mouse_over ,onmouse_click);
a.removeeventlistener(mouseevent.mouse_down ,onmouse_click);
a.removeeventlistener(mouseevent.mouse_out ,onmouse_click);
}
}
// 开始使用可用数码按键功能
function show_balls_seleabled(a_arr:array,b_arr:array) {
var a_array:array=a_arr,b_array:array=b_arr;
for (var i:uint =0; i<a_array.length; i++) {
var a:movieclip =a_array;
a.buttonmode =true;
a.mousechildren=false;
a.addeventlistener(mouseevent.mouse_over ,onmouse_click);
a.addeventlistener(mouseevent.mouse_down ,onmouse_click);
a.addeventlistener(mouseevent.mouse_out ,onmouse_click);
}
for (var j:uint =0; j<b_array.length; j++) {
var b:movieclip =b_array[j];
b.filters =门里出身;
b.buttonmode =false;
b.removeeventlistener(mouseevent.mouse_over ,onmouse_click);
b.removeeventlistener(mouseevent.mouse_down ,onmouse_click);
b.removeeventlistener(mouseevent.mouse_out ,onmouse_click);
}
}
gong_mc.close_变态n.addeventlistener(mouseevent.mouse_down,oncloseshowgong);
function oncloseshowgong(sxl:mouseevent) {
rect_down_sound.play();
gong_mc.addeventlistener(event.enter_frame,move_gong_mc_rect);
}
function move_gong_mc_rect(sxl:event) {
if (move_gong_mc) {
var dis_up:number =(300-sxl.target.y)/5;
sxl.target.y+=dis_up;
if (math.abs(dis_up)<1) {
_win.play();
sxl.target.gold.play();
sxl.target.y=300;
sxl.target.removeeventlistener(event.enter_frame,move_gong_mc_rect);
move_gong_mc=false;
}
} else {
var dis_down:number =(1000-sxl.target.y)/5;
sxl.target.y+=dis_down;
if (math.abs(dis_down)<10) {
sxl.target.y=1000;
sxl.target.removeeventlistener(event.enter_frame,move_gong_mc_rect);
move_gong_mc=true;
show_balls_seleabled(balls,hit_ball_array);
}
}
}
function randomarray(target_array:array):void {
target_array.sort(function () {
return math.round(math.random()) ? 1 : -1;
});
}
function settxtcolor(_txt:textfield,color:uint=0×666666) {
var my_textformat:textformat =new textformat();
my_textformat.color =color;
_txt.defaulttextformat = my_textformat;
_txt.settextformat(my_textformat);
}
//… 投影
function getbitmapfilter(_mc:movieclip) {
var color:number = 0×000000;
var angle:number = 45;
var alpha:number = 0.8;
var blurx:number = 8;
var blury:number = 8;
var distance:number = 15;
var strength:number = 0.65;
var inner:boolean = false;
var knockout:boolean = false;
var quality:number = bitmapfilterquality.high;
var mydropshadowfilterropshadowfilter= new dropshadowfilter(distance,angle,color,alpha,blurx,blury,strength,quality,inner,knockout);
_mc.filters =[mydropshadowfilter];
}

以上就是flash cs制造幸运大抽奖gif动画特效教程,期望大家喜欢!