公司网站如何seo,邹城网站开发,本地网站建设教程xampp,阿里云做网站可以免备案吗目录
一、链接#xff1a;
一、目的
1、因为很多都有倒计时图片切换#xff0c;所以我封装一个倒计时的资源#xff0c;以后直接从flash赋复制#xff0c;交换一下资源就可以了
二、参考
1、AS3自定义事件以及发送事件#xff08;1#xff09;——发送事件
三、操作…目录
一、链接
一、目的
1、因为很多都有倒计时图片切换所以我封装一个倒计时的资源以后直接从flash赋复制交换一下资源就可以了
二、参考
1、AS3自定义事件以及发送事件1——发送事件
三、操作写在自定义类中版本3.1
1、其余设置和版本3.1等类似
1、代码自定义类My_countDown
1、关键帧中调用
三、操作写在自定义类中版本3.1
1、项目设置
2、My_countDown 代码
3、关键帧代码调用倒计时
三、操作写在自定义类中版本2.0
1、项目设置
1、关键帧代码调用倒计时
1、 自定义类My_countDown
三、操作写在关键帧中
1、项目设置
1、元件数字
1、元件 mc_time_task
1、配置文件config-flash.xml
1、配置文件关键帧代码
1、倒计时关键帧代码 一、链接
https://download.csdn.net/download/qq_40544338/12921178
一、目的
1、因为很多都有倒计时图片切换所以我封装一个倒计时的资源以后直接从flash赋复制交换一下资源就可以了 二、参考
1、AS3自定义事件以及发送事件1——发送事件
https://blog.csdn.net/qq_40544338/article/details/108992347 总结知道自定义类发送消息给舞台 三、操作写在自定义类中版本3.1
1、其余设置和版本3.1等类似
1、代码自定义类My_countDown
/**********************/
// 作者xzy
//功能自定义类让舞台添加物体有开始、停止、重置定时器最多实现3位倒计时
//日期20201010
//版本3.1
/**********************//*
完善
版本3.2和3.1相比添加了Clear函数对象移除添加的监听事件
版本3.1和3.0相比添加初始化函数Init不通过构造函数进行创建定时器而是通过初始化函数Init
版本3.0和2.0相比创建时候数字元件跳到传递来的数字。
*/package MyLibrary
{import flash.display.MovieClip;import flash.utils.Timer;import flash.events.TimerEvent;import flash.events.Event;public class My_countDown extends MovieClip{//发送监听事件static public const START:String START;static public const OVER:String OVER;//任务总时长单位秒public var timer_task_total:int 0;//任务当前时间public var timer_task_current:int 0;//定时器任务public var timer_task:Timer null;/*构造函数My_countDown*/public function My_countDown(){}public function Init(_total:int){timer_task_total _total;Set_changeTime();//定时器:任务倒计时;if (timer_tasknull){timer_task new Timer(1000,timer_task_total);if (! timer_task.hasEventListener(TimerEvent.TIMER)){timer_task.addEventListener(TimerEvent.TIMER,TIMER_timer_task);}}}public function Clear(){//定时器:任务倒计时;if (timer_task!null){timer_task.stop();if (timer_task.hasEventListener(TimerEvent.TIMER)){timer_task.removeEventListener(TimerEvent.TIMER,TIMER_timer_task);}timer_task null;}}//定时器任务倒计时public function TIMER_timer_task(e:TimerEvent){timer_task_current;//trace(timer_task_current:timer_task_current);Set_changeTime();//倒计时结束if (timer_task_currenttimer_task_total){timer_task.stop();//分发OVER事件;dispatchEvent(new Event(OVER));//新建事件传入String参数}}//开始定时器public function Set_start(){timer_task.start();//分发START事件;dispatchEvent(new Event(START));//新建事件传入String参数}//重置定时器public function Set_reset(){timer_task.reset();}//结束定时器public function Set_stop(){timer_task.stop();}/*功能设置更换时间元件参数_showKind显示的种类0只显示个位 1显示个位和十位 2显示个位、十位、百位*/public function Set_changeTime(){var currentTime:int timer_task_total - timer_task_current;//百位var currentTime_baiWei:int currentTime / 100;//十位var currentTime_shiWei:int (currentTime - currentTime_baiWei * 100) / 10;//个位var currentTime_geWei:int currentTime - currentTime_baiWei * 100 - currentTime_shiWei * 10;if (currentTime_baiWei0){currentTime_baiWei 10;}if (currentTime_shiWei0){currentTime_shiWei 10;}if (currentTime_geWei0){currentTime_geWei 10;}//this.mc_time_bai.gotoAndStop(currentTime_baiWei);this.mc_time_shi.gotoAndStop(currentTime_shiWei);this.mc_time_ge.gotoAndStop(currentTime_geWei);}}}
1、关键帧中调用
创建
//任务倒计时
import MyLibrary.My_countDown;//创建:任务倒计时my_countDown.Init(timer_task_total);if (!my_countDown.hasEventListener(My_countDown.OVER)){my_countDown.addEventListener(My_countDown.OVER,OVER_my_countDown);}
清除 //任务倒计时移除添加的事件my_countDown.Clear();
开启定时器 //任务倒计时开始计时 my_countDown.Set_reset();my_countDown.Set_start();
相应自定义类时间到了
//任务时间到了
function OVER_my_countDown(e:Event)
{trace(任务时间到了);Destroy_game();gotoAndStop(失败);
} 三、操作写在自定义类中版本3.1
1、项目设置 2、My_countDown 代码
/**********************/
// 作者xzy
//功能自定义类让舞台添加物体有开始、停止、重置定时器最多实现3位倒计时
//日期20201010
//版本3.1
/**********************//*
完善
版本3.1和3.0相比添加初始化函数Init不通过构造函数进行创建定时器而是通过初始化函数Init
版本3.0和2.0相比创建时候数字元件跳到传递来的数字。
*/package MyLibrary
{import flash.display.MovieClip;import flash.utils.Timer;import flash.events.TimerEvent;import flash.events.Event;public class My_countDown extends MovieClip{//发送监听事件static public const START:String START;static public const OVER:String OVER;//任务总时长单位秒public var timer_task_total:int 0;//任务当前时间public var timer_task_current:int 0;//定时器任务public var timer_task:Timer null;/*构造函数My_countDown*/public function My_countDown(){//timer_task_total _total;////Set_changeTime();//定时器:任务倒计时;//if (timer_tasknull)//{//timer_task new Timer(1000,timer_task_total);//if (! timer_task.hasEventListener(TimerEvent.TIMER))//{//timer_task.addEventListener(TimerEvent.TIMER,TIMER_timer_task);//}//}}public function Init(_total:int){timer_task_total _total;Set_changeTime();//定时器:任务倒计时;if (timer_tasknull){timer_task new Timer(1000,timer_task_total);if (! timer_task.hasEventListener(TimerEvent.TIMER)){timer_task.addEventListener(TimerEvent.TIMER,TIMER_timer_task);}}}//定时器任务倒计时public function TIMER_timer_task(e:TimerEvent){timer_task_current;//trace(timer_task_current:timer_task_current);Set_changeTime();//倒计时结束if (timer_task_currenttimer_task_total){timer_task.stop();//分发OVER事件;dispatchEvent(new Event(OVER));//新建事件传入String参数}}//开始定时器public function Set_start(){timer_task.start();//分发START事件;dispatchEvent(new Event(START));//新建事件传入String参数}//重置定时器public function Set_reset(){timer_task.reset();}//结束定时器public function Set_stop(){timer_task.stop();}/*功能设置更换时间元件参数_showKind显示的种类0只显示个位 1显示个位和十位 2显示个位、十位、百位*/public function Set_changeTime(){var currentTime:int timer_task_total - timer_task_current;//百位var currentTime_baiWei:int currentTime / 100;//十位var currentTime_shiWei:int (currentTime - currentTime_baiWei * 100) / 10;//个位var currentTime_geWei:int currentTime - currentTime_baiWei * 100 - currentTime_shiWei * 10;if (currentTime_baiWei0){currentTime_baiWei 10;}if (currentTime_shiWei0){currentTime_shiWei 10;}if (currentTime_geWei0){currentTime_geWei 10;}//this.mc_time_bai.gotoAndStop(currentTime_baiWei);this.mc_time_shi.gotoAndStop(currentTime_shiWei);this.mc_time_ge.gotoAndStop(currentTime_geWei);}}} 3、关键帧代码调用倒计时
import MyLibrary.My_countDown;stop();Start_countDown();//功能初始化
function Start_countDown()
{//创建:任务倒计时 my_countDown.Init(timer_task_total);//任务倒计时开始计时my_countDown.Set_start();}//功能离开此场景需要移除的东西;
function Destroy_countDown()
{} 三、操作写在自定义类中版本2.0
1、项目设置 1、关键帧代码调用倒计时
import MyLibrary.My_countDown;var my_countDown:My_countDown null;stop();Start_countDown();//功能初始化
function Start_countDown()
{//初始化倒计时Init_countDown();
}//功能离开此场景需要移除的东西;
function Destroy_countDown()
{//移除 任务倒计时if (my_countDown!null){if (my_countDown.hasEventListener(My_countDown.START)){my_countDown.removeEventListener(My_countDown.START,START_countDown);}if (my_countDown.hasEventListener(My_countDown.OVER)){my_countDown.removeEventListener(My_countDown.OVER,OVER_countDown);}if (stage.contains(my_countDown)){stage.removeChild(my_countDown);}}
}//初始化倒计时
function Init_countDown()
{//初始化任务倒计时if (my_countDownnull){my_countDown new My_countDown(2);//倒计时几秒//添加监听事件if (! my_countDown.hasEventListener(My_countDown.START)){my_countDown.addEventListener(My_countDown.START,START_countDown);}if (! my_countDown.hasEventListener(My_countDown.OVER)){my_countDown.addEventListener(My_countDown.OVER,OVER_countDown);}if (! stage.contains(my_countDown)){stage.addChild(my_countDown);}}my_countDown.Set_start();
}function START_countDown(e:Event):void
{trace(e);//(2)
}function OVER_countDown(e:Event):void
{trace(e);//(4)
}
1、 自定义类My_countDown
/**********************/
// 作者xzy
//功能自定义类让舞台添加物体有开始、停止、重置定时器最多实现3位倒计时
//日期20201010
//版本2.0
/**********************/
package MyLibrary
{import flash.display.MovieClip;import flash.utils.Timer;import flash.events.TimerEvent;import flash.events.Event;public class My_countDown extends MovieClip{//发送监听事件static public const START:String START;static public const OVER:String OVER;//任务总时长单位秒public var timer_task_total:int 0;//任务当前时间public var timer_task_current:int 0;//定时器任务public var timer_task:Timer null;public function My_countDown(_total:int){timer_task_total _total;//倒计时原件暂停this.mc_time_bai.gotoAndStop(1);this.mc_time_shi.gotoAndStop(1);this.mc_time_ge.gotoAndStop(1);//定时器:任务倒计时;if (timer_tasknull){timer_task new Timer(1000,timer_task_total);if (! timer_task.hasEventListener(TimerEvent.TIMER)){timer_task.addEventListener(TimerEvent.TIMER,TIMER_timer_task);}}}//定时器任务倒计时public function TIMER_timer_task(e:TimerEvent){timer_task_current;trace(timer_task_current:timer_task_current);Set_changeTime();//倒计时结束if (timer_task_currenttimer_task_total){timer_task.stop();//分发OVER事件;dispatchEvent(new Event(OVER));//新建事件传入String参数}}//开始定时器public function Set_start(){timer_task.start();//分发START事件;dispatchEvent(new Event(START));//新建事件传入String参数}//重置定时器public function Set_reset(){timer_task.reset();}//结束定时器public function Set_stop(){timer_task.stop();}//设置更换时间public function Set_changeTime(){var currentTime:int timer_task_total - timer_task_current;//百位var currentTime_baiWei:int currentTime / 100;//十位var currentTime_shiWei:int (currentTime - currentTime_baiWei * 100) / 10;//个位var currentTime_geWei:int currentTime - currentTime_baiWei * 100 - currentTime_shiWei * 10;if (currentTime_baiWei0){currentTime_baiWei 10;}if (currentTime_shiWei0){currentTime_shiWei 10;}if (currentTime_geWei0){currentTime_geWei 10;}this.mc_time_bai.gotoAndStop(currentTime_baiWei);this.mc_time_shi.gotoAndStop(currentTime_shiWei);this.mc_time_ge.gotoAndStop(currentTime_geWei);}}} 三、操作写在关键帧中
1、项目设置 1、元件数字
1-9帧对应1-9图片10帧是0图片 1、元件 mc_time_task 1、配置文件config-flash.xml
ConfigTimetimer_task_total5/timer_task_total !--任务总时长单位秒--/Time
/Config1、配置文件关键帧代码
import flash.net.URLRequest;
import flash.net.URLLoader;fscommand(fullscreen,true);stop();//任务总时长单位秒
var timer_task_total:int0;
var timer_task_current:int 0;
var timer_task:Timernull;//获取一个xml文件
var url:URLRequest null;
//使用URLLoader导入数据
var loadurl:URLLoader null;Start_config();//功能初始化
function Start_config()
{if (urlnull){url new URLRequest(config-flash.xml);}if (loadurlnull){loadurl new URLLoader(url);}//添加事件******以在XML数据导入完成后处理XML数据;if (! loadurl.hasEventListener(Event.COMPLETE)){loadurl.addEventListener(Event.COMPLETE,Loadxml);}
}//功能离开此场景需要移除的东西
function Destroy_config()
{
}//功能读取配置文件
function Loadxml(event:Event)
{ var xml:XML XML(loadurl.data);//导入完成后使用导入的数据创建XML对象timer_task_total xml.Time.timer_task_total;trace(timer_task_total:timer_task_total);Destroy_config();gotoAndStop(倒计时);
}
1、倒计时关键帧代码
stop();Start_countDown();//功能初始化
function Start_countDown()
{//初始化倒计时Init_countDown();
}//功能离开此场景需要移除的东西;
function Destroy_countDown()
{//移除任务倒计时timer_task.stop();if (timer_task.hasEventListener(TimerEvent.TIMER)){timer_task.removeEventListener(TimerEvent.TIMER,TIMER_timer_task);timer_task null;}
}//初始化倒计时
function Init_countDown()
{mc_time_task.mc_time_bai.stop();mc_time_task.mc_time_shi.stop();mc_time_task.mc_time_ge.stop();//定时器:任务倒计时if (timer_tasknull){timer_task new Timer(1000,timer_task_total);if (! timer_task.hasEventListener(TimerEvent.TIMER)){timer_task.addEventListener(TimerEvent.TIMER,TIMER_timer_task);}}timer_task.start();
}//定时器任务倒计时
function TIMER_timer_task(e:TimerEvent)
{timer_task_current;trace(timer_task_current:timer_task_current);ShowTime();if (timer_task_currenttimer_task_total){timer_task.stop();trace(游戏结束);}
}//显示时间
function ShowTime()
{var currentTime:int timer_task_total - timer_task_current;//百位var currentTime_baiWei:int currentTime / 100;//十位var currentTime_shiWei:int (currentTime - currentTime_baiWei * 100) / 10;//个位var currentTime_geWei:int currentTime - currentTime_baiWei * 100 - currentTime_shiWei * 10;if (currentTime_baiWei0){currentTime_baiWei 10;}if (currentTime_shiWei0){currentTime_shiWei 10;}if (currentTime_geWei0){currentTime_geWei 10;}mc_time_task.mc_time_bai.gotoAndStop(currentTime_baiWei);mc_time_task.mc_time_shi.gotoAndStop(currentTime_shiWei);mc_time_task.mc_time_ge.gotoAndStop(currentTime_geWei);}