且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 flex-as3 的循环中显示进程的当前progressBar 值?

更新时间:2022-06-09 03:05:47

这是可能的,只是在您需要使用计时器时.

It is possible, just instead for or while you need to use Timers.

import flash.utils.Timer;
import flash.events.TimerEvent;

var loopNum : uint = 17598; // loop length ( forrmer for or while limit )
var tick : uint = 0;

var timer:Timer = new Timer ( 10, loopNum );
timer.addEventListener ( TimerEvent.TIMER, handleLoopTick );
timer.start ();

function handleLoopTick ( e : TimerEvent )
{
    trace ( this, ( tick / loopNum ) * 100 ); // outputs percentage for example

    tick++; // increasing the tick
}