package com{ import flash.display.MovieClip; import flash.utils.Timer; import flash.events.TimerEvent; import flash.text.TextField; public class CutTime extends MovieClip { public static var timer:Timer; public static var countTimes:Number = 30; public static var moveMc:MovieClip; public static var startX:Number; public static var txt:TextField; public function CutTime(_moveMc:MovieClip,_txt:TextField) { txt = _txt; moveMc = _moveMc; timer = new Timer(25); timer.addEventListener(TimerEvent.TIMER,onTimer); timer.start(); startX = moveMc.x - moveMc.width; moveMc.x = startX; } public static function inint() { moveMc.x = startX; timer.start(); trace("弹框小时候执行的"); } public function onTimer(e:TimerEvent) { moveMc.x = moveMc.width * timer.currentCount / (countTimes * 40) + startX; var num:uint = countTimes - timer.currentCount / 40; txt.text = num.toString() + "S"; //trace(num,countTimes+":j进度条倒计时",timer.currentCount) if (num==countTimes) { timer.reset(); } } } }
标签:AS3.0,moveMc,进度条,timer,倒计时,static,var,txt,public From: https://www.cnblogs.com/zqiang0803/p/16869793.html