Flash CS制作幸运大抽奖gif动画特效教程
平面设计 2021-07-03 14:35www.168986.cn平面设计培训
好久未来这了,刚好这两天没什么事,又做了一个抽奖的小东东玩玩,只供菜鸟们参考,老鸟们见笑了。
照惯例上主要代码
复制代码
代码如下:s();
/
@sxl
@QQ:285510591
@http://sxl001.129hb.
@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, pleteHNum);
dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
}
function pleteHNum(event:Event):void {
gong_array =event.target.data.split("|");
randomArray(gong_array);
event.target.removeEventListener(Event.COMPLETE, pleteHNum);
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_btn.enabled=false;
gong_mc.close_btn.removeEventListener(MouseEvent.MOUSE_DOWN,onCloseShowGong);
event.target.removeEventListener(Event.COMPLETE, pleteHNum);
event.target.removeEventListener(Event.COMPLETE, ioErrorHandler);
}
/
for (var i:uint =0; i<30; i++) {
this["Ball" + i].cacheAsBitmap=true;
this["Ball" + i].gotoAndS("one");
Balls.push(this["Ball" + i]);
msg_mc["m" + i].ball_mc.gotoAndS("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 =null;
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.gotoAndS("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 =null;
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_btn.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=0x666666) {
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 = 0x000000;
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动画特效教程,希望大家喜欢! /
@sxl
@QQ:285510591
@http://sxl001.129hb.
@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, pleteHNum);
dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
}
function pleteHNum(event:Event):void {
gong_array =event.target.data.split("|");
randomArray(gong_array);
event.target.removeEventListener(Event.COMPLETE, pleteHNum);
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_btn.enabled=false;
gong_mc.close_btn.removeEventListener(MouseEvent.MOUSE_DOWN,onCloseShowGong);
event.target.removeEventListener(Event.COMPLETE, pleteHNum);
event.target.removeEventListener(Event.COMPLETE, ioErrorHandler);
}
/
for (var i:uint =0; i<30; i++) {
this["Ball" + i].cacheAsBitmap=true;
this["Ball" + i].gotoAndS("one");
Balls.push(this["Ball" + i]);
msg_mc["m" + i].ball_mc.gotoAndS("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 =null;
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.gotoAndS("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 =null;
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_btn.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=0x666666) {
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 = 0x000000;
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];
}
平面设计师
- 平面设计图怎么画 小学生画平面图
- 平面设计内容怎么写 平面设计的求职意向怎么写
- 平面设计图手绘 平面设计图手绘家具
- 平面设计多久能出师 平面设计要多久
- 女生做ui设计师有多累 女生为什么学ui的人很惨
- 哪里有学平面设计的学校 想学平面设计去哪里学
- 初学平面设计用哪个软件 平面设计初学者必备的
- 0基础学平面设计要多久 0基础自学平面设计
- 平面设计手绘培训 平面设计师培训班学费多少钱
- ui工作好找工作吗 ui好不好找工作
- 女生学室内设计吃香吗
- ps平面设计自学教程 平面设计ps入门教程
- 平面设计基础知识大全 平面设计基本常识
- 平面设计基础教学视频 平面设计教学零基础入门
- 平面设计基础教学 平面设计基础教学平时作业
- ui设计主要是学什么 ui设计一般是学什么