如何显示过程的柔性AS3一个循环内的当前进度值? [英] How to show the current progressBar value of process within a loop in flex-as3?

查看:77
本文介绍了如何显示过程的柔性AS3一个循环内的当前进度值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何来显示ProgressBar组件目前的进展时,这个过程是需要很多秒钟来完成这项工作循环。 在循环中,我setProgress并更新在每cicle的进度标签,但它未示出到工作已经完成。我不需要这个,因为我希望看到进程的推进。 谢谢你。

I dont know how to show the current progress in progressBar component when the process is a loop that requires a lot of seconds to do the job. Inside the loop, i setProgress and update the progressBar label in every cicle, but it is not shown up to the job is done. I dont need this, because i want to see the advance of process. thank you.

推荐答案

这是可能的,而不是仅仅为或者当你需要使用定时器。

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
}

这篇关于如何显示过程的柔性AS3一个循环内的当前进度值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆