FLASH教程之Flash CS实例教程:侥幸年夜抽奖动画-Flash actionscript
用flash动画制作软件制作的动画文件很小,这样便于在互联网上传输,而且它采用了流技术,只要下载一部分,就能欣赏动画,而且能一边播放一边传输送数据。poluoluo中心提醒:flash抽奖程序制造:侥幸年夜抽奖.
很久将来这了,恰好这两天没甚么事,又做了一个抽奖的小东东玩玩,只供菜鸟们参考,老鸟们见笑了。
照常规上次要代码:
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;
//以下是声响效果数据
varmousw_over_sound:Over=newOver(),rect_up_sound:Move=newMove(),rect_down_soundown=newDown(),_win:Win=newWin();
//gong_array:奖品名|Balls:各个号码|hit_ball_array:已抽号码
vargong_array:Array=[],Balls:Array=[],hit_ball_array:Array=[],move_gong_mc:Boolean=true,move_msg_mc:Boolean;
//以下是外部设置奖品
vardata_str:String="环保手提袋|罗技|电磁炉|显现器|挪动硬盘|掌下游戏机|手机|3G手机|九阳豆乳机|电动剃须刀|雅顿喷鼻水|数码相机|闪存盘|离子电视|消毒柜|松下洗衣机|电磁炉|电饭煲|电压力锅|光波炉|搅拌机|榨汁机|电茶壶|咖啡机|主动烹调锅|紫砂煲|空调|吸油烟机|取暖和器|加湿器";
gong_array=data_str.split("|");
randomArray(gong_array);
/*以下正文部分是从内部文本中导进奖品数据
varloaderNum:URLLoader=newURLLoader();
configureListenersNum(loaderNum);
varurlNum:String="data/奖品.txt";
varrequestNum:URLRequest=newURLRequest(urlNum);
loaderNum.load(requestNum);
functionconfigureListenersNum(dispatcher:IEventDispatcher):void{
dispatcher.addEventListener(Event.COMPLETE,completeHNum);
dispatcher.addEventListener(IOErrorEvent.IO_ERROR,ioErrorHandler);
}
functioncompleteHNum(event:Event):void{
gong_array=event.target.data.split("|");
randomArray(gong_array);
event.target.removeEventListener(Event.COMPLETE,completeHNum);
event.target.removeEventListener(Event.COMPLETE,ioErrorHandler);
}
functionioErrorHandler(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,completeHNum);
event.target.removeEventListener(Event.COMPLETE,ioErrorHandler);
}
*/
for(vari: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);
functiononMouse_Click(sxl:MouseEvent){
vartarget:MovieClip=sxl.currentTargetasMovieClip;
vartarget_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.gotoAndStop("two");
setTxtColor(target._txt);
varindex:String=target.i;
hit_ball_array.push(target);
varstr: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;
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;
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;
}
}
//
functionshow_msg_mc(sxl:Event){
if(move_msg_mc){
vardis_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{
vardis_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);
}
}
}
//删除一切数字按钮功效
functiondele_balls_seleabled(){
for(vari:uint=0;i<Balls.length;i++){
varA: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);
}
}
//启用可用数字按钮功效
functionshow_balls_seleabled(A_arr:Array,B_arr:Array){
varA_array:Array=A_arr,B_array:Array=B_arr;
for(vari:uint=0;i<A_array.length;i++){
varA: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(varj:uint=0;j<B_array.length;j++){
varB:MovieClip=B_array;
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);
functiononCloseShowGong(sxl:MouseEvent){
rect_down_sound.play();
gong_mc.addEventListener(Event.ENTER_FRAME,move_gong_mc_rect);
}
functionmove_gong_mc_rect(sxl:Event){
if(move_gong_mc){
vardis_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{
vardis_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);
}
}
}
functionrandomArray(Target_array:Array):void{
Target_array.sort(function(){
returnMath.round(Math.random())?1:-1;
});
}
functionsetTxtColor(_txt:TextField,color:uint=0x666666){
varmy_TextFormat:TextFormat=newTextFormat();
my_TextFormat.color=color;
_txt.defaultTextFormat=my_TextFormat;
_txt.setTextFormat(my_TextFormat);
}
//...投影
functiongetBitmapFilter(_mc:MovieClip){
varcolor:Number=0x000000;
varangle:Number=45;
varalpha:Number=0.8;
varblurX:Number=8;
varblurY:Number=8;
vardistance:Number=15;
varstrength:Number=0.65;
varinner:Boolean=false;
varknockout:Boolean=false;
varquality:Number=BitmapFilterQuality.HIGH;
varmyDropShadowFilterropShadowFilter=newDropShadowFilter(distance,angle,color,alpha,blurX,blurY,strength,quality,inner,knockout);
_mc.filters=;
}
源码下载:抽奖机.rar
“fla”是Flash的原始档,只能用对应版本或更高版本的Flash打开编辑。 flash制作的动画文件比较小,可以在网络上快速传播! 对插件的批评之一是他们一般出现在称为Box的网页的一个预定的区域。虽然在某种情况下表现不错,但Box经常以罪魁祸首的面目出现。 传播上的优势——无国界跨媒体;创作群体的形成;媒体及比赛的推进 只要用心 只要努力 在加上你无限的创意和想象。FLASH无敌了 Flash使交互性容易,并且消除了学习某种语言的需要。折中办法是不学语言,同时失去一些功能。但是你仍然可以处理基于用户动作(如鼠标移动或点击)的触发事件,这通常是你需要的所有交互性。 常见的富媒体广告形式有横幅广告(BANNER,旗帜广告)按钮广告(BUTTON)弹出窗口广告(pop-up ads,弹窗)浮动广告(floting ads,飘浮广告,floaters)插播式广告(Interstitial)全屏广告(full screen) 广告本身无法看到网址链接,不利于网站本身的搜索引擎优化,对增加网站排行的权重没有意义。
页:
[1]