用flash as3.0制作一个10分钟倒计时(精确到毫秒)!求源代码~~
答案:2 悬赏:0 手机版
解决时间 2021-04-07 08:19
- 提问者网友:蔚蓝的太阳
- 2021-04-06 11:06
用flash as3.0制作一个10分钟倒计时(精确到毫秒)!求源代码~~
最佳答案
- 五星知识达人网友:执傲
- 2021-04-06 12:05
package{
import flash.display .MovieClip;
import flash.events .*;
import flash.utils.Timer ;
import flash.text.TextField;
public class Dao extends MovieClip{
var txt:TextField;
var i:Number=1;
var myTimer:Timer;
var zong:Number;
var m:int;
var s:int;
var hs:int;
//var ts:int;
//var tm:int;
//var tms:int;
public function Dao(){
txt=new TextField();
txt.x=150;
txt.y=200;
txt.width=300;
addChild(txt);
myTimer= new Timer(10);
btn1.addEventListener(MouseEvent.CLICK,mc);
btn2.addEventListener(MouseEvent.CLICK,mp);
}
public function mc(Event:MouseEvent) {
myTimer.addEventListener(TimerEvent.TIMER, showText);
myTimer.start();
}
public function showText(event:TimerEvent) :void{
zong=10*60*100-i;
m=int(zong/100/60);
s=int(zong/100%60);
hs=int(zong%100);
//m=int(zong/100/60);
//s=int(zong/100/10);
//hs=int(zong/10/60);
txt.text="倒计开始:"+m+"分"+s+"秒"+hs+"毫秒";
i++;
}
public function mp(Event:MouseEvent) {
myTimer.stop();
}
}
}
import flash.display .MovieClip;
import flash.events .*;
import flash.utils.Timer ;
import flash.text.TextField;
public class Dao extends MovieClip{
var txt:TextField;
var i:Number=1;
var myTimer:Timer;
var zong:Number;
var m:int;
var s:int;
var hs:int;
//var ts:int;
//var tm:int;
//var tms:int;
public function Dao(){
txt=new TextField();
txt.x=150;
txt.y=200;
txt.width=300;
addChild(txt);
myTimer= new Timer(10);
btn1.addEventListener(MouseEvent.CLICK,mc);
btn2.addEventListener(MouseEvent.CLICK,mp);
}
public function mc(Event:MouseEvent) {
myTimer.addEventListener(TimerEvent.TIMER, showText);
myTimer.start();
}
public function showText(event:TimerEvent) :void{
zong=10*60*100-i;
m=int(zong/100/60);
s=int(zong/100%60);
hs=int(zong%100);
//m=int(zong/100/60);
//s=int(zong/100/10);
//hs=int(zong/10/60);
txt.text="倒计开始:"+m+"分"+s+"秒"+hs+"毫秒";
i++;
}
public function mp(Event:MouseEvent) {
myTimer.stop();
}
}
}
全部回答
- 1楼网友:舍身薄凉客
- 2021-04-06 13:21
这种样子的,行吗?
追问可以~可以把代码发给我吗?
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯