dcsimg
A Flash Developer Resource Site

Results 1 to 11 of 11

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

  1. #1
    Member
    Join Date
    Jan 2004
    Location
    israel
    Posts
    90

    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
    Last edited by davidkhen; 01-23-2007 at 09:54 AM.

  2. #2
    Member
    Join Date
    Jan 2004
    Location
    israel
    Posts
    90
    somebody please ... ?

  3. #3
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    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?
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    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. #5
    Member
    Join Date
    Jan 2004
    Location
    israel
    Posts
    90
    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. #6
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    I think why we are confused is the word faster. It would actually take more code to make sure that this took 7 minutes.
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  7. #7
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    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. #8
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668
    setInterval was the way I was going to go as well
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  9. #9
    Member
    Join Date
    Jan 2004
    Location
    israel
    Posts
    90
    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
    please take a look,
    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. #10
    OOP is one letter from OOPS kortex's Avatar
    Join Date
    Aug 2005
    Location
    New Hope, PA
    Posts
    2,668

    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 yrsStart:Date = new Date();
    var yrsEnd:Date = new Date();
    yrsStart.setYear(1957);
    yrsEnd.setYear(2007);
    trace(yrsStart.getFullYear()+" "+yrsEnd.getFullYear());
    for (i=yrsStart.getFullYear(); i<=yrsEnd.getFullYear(); i++) {
    	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)
    Last edited by kortex; 09-04-2007 at 03:27 PM.
    Jeremy Wischusen
    Flash - Flex - LAMP - Web Developer Purple Inc
    AS OOP FAQ-Best Practices Thread | Flashkit OOP Tutorials | Purple Inc (day job) | Blog


  11. #11
    Member
    Join Date
    Jan 2004
    Location
    israel
    Posts
    90
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center