A Flash Developer Resource Site

Thread: count numbers from 1 - 29,000 in 7 min...

1. counting numbers from 1 - 29,000 in 7 min...

hello there
please help, need to count numbers faster from num. 1 to 29,000 with duration of 7 min...

many thanks
David

3. Faster???

When I ran this:

var startVal:Number = 1;
var endVal:Number = 29000;
var startTime = getTimer();
trace ("Start Time: =" + startTime)
for (i= startVal; i<endVal;i++){

}
var endTime = getTimer()
trace ("Elapsed time = " + (endTime-startTime));

It traced:
Start Time: =23
Elapsed time = 90

Meaning the whole thing took 90 milliseconds.

Could you explain a bit more about what you are doing?

4. can you explain what you are trying to do with 29,000 and 7 minutes
what code do you have so far ?

edit : kortex beat me to it

5. thanks ...
i have to make a presentation, with 7 minutes of duration
and i have to include in it a numbers that runs from 1 to 29000 like timer...
??

6. I think why we are confused is the word faster. It would actually take more code to make sure that this took 7 minutes.

7. this is prolly innaccurate but may help
Code:
var mins:Number = 7;
var msec:Number = mins*60000; // 7 mins in milliseconds - 420000
var div:Number = msec/29000; // divisor = 14.4827586206897
var count:Number = 0;

function tracer(){
count++;
trace(count);
trace(getTimer()+"milliseconds");
if(count == 29000) clearInterval(traceInt);
}

traceInt = setInterval(tracer,div);
kortex, do you have a better/ more accurate idea ?

8. setInterval was the way I was going to go as well

9. first of all thank's...
but i can't make the code to run...

a have uploaded the image of a presentation in my server
http://www.igdm.co.il/david/presentation.gif

the numbers must to run from 1 up to 29000
and years from 1957 up to 2007
the duration of this must to be at lest 7 minute ...
thanks again
david

10. Example FLA

Here is some sample code: See attached FLA as an example:

Code:
var nmbr:Number = 1;
var yrInterval:Number = Math.floor((7*60*1000)/29000);

trace ("Year interval = "+ yrInterval);
var yrs:Array = new Array();
var yrsEnd:Date = new Date();
yrsEnd.setYear(2007);
yrs.push(i);
}
//trace (yrs);
var nmbrInterval:Number = Math.floor((7*60*1000)/yrs.length)
var yrsIndex:Number = 0;
function updateYrs() {
_root.yrs_txt.text = yrs[yrsIndex].toString();
trace("updating years to "+yrs[yrsIndex].toString()+" years text = "+ _root.yrs_txt.text);
yrsIndex++;
if (yrsIndex == yrs.length) {
clearInterval(setYrs);
}
}
updateYrs();
var setYrs = setInterval(updateYrs, nmbrInterval);
function updateNumber(){
_root.nmbr_txt.text = nmbr;
nmbr++
if (nmbr >= 29000){
clearInterval(setNum);
}
}
var setNum = setInterval(updateNumber, yrInterval)

11. kortex - i really don't know how to thank you ...
it's excelent, and 100% what i needed
just many thanks to you

David

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap