A Flash Developer Resource Site

Results 1 to 17 of 17

Thread: [F8] Nanoseconds

  1. #1
    Software Developer mickm's Avatar
    Join Date
    Sep 2006
    Location
    Kingston [ON]
    Posts
    115

    [F8] Nanoseconds

    Hi everyone, long time since I have posted

    Is there any way to get the number of Nanoseconds in flash?
    I know you can get the number of Milliseconds and divide by 1000 to get nanoseconds. But that isn't accurate enough.

    I would like to use the nanoseconds because I am making a small reflex game. Milliseconds just aren't fast enough (too many people can get the same number twice.)



    Thanks.
    Post you game for free at Gamestack.org. We send the user straight to your website, no iFrames or other leeching methods.

    Please check out Gamestack.org for more information.

  2. #2
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    flash can´t but maybe java can and pass it through

    or maybe you hust need more factors for a variety- like motion capturing instead of digital button hitting

  3. #3
    Software Developer mickm's Avatar
    Join Date
    Sep 2006
    Location
    Kingston [ON]
    Posts
    115
    Thanks renderhjs, I guess ill look for some other ways to test reflexes instead of getTimer()
    Post you game for free at Gamestack.org. We send the user straight to your website, no iFrames or other leeching methods.

    Please check out Gamestack.org for more information.

  4. #4
    Knows where you live
    Join Date
    Oct 2004
    Posts
    944
    Perhaps its just flashes frame system messing with the results? I haven't tested any of this, but perhaps the getTimer only gets the times of the nearest frame instead of the precise moment of clickage?
    The greatest pleasure in life is doing what people say you cannot do.
    - Walter Bagehot
    The height of cleverness is to be able to conceal it.
    - Francois de La Rochefoucauld

  5. #5
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    ...just thinking of it... maybe there is a way
    dont know what the frame rate limit is in flash (lets forget once about the browser limitation here) - maybe you could try increasing a counter on each frame or interval event so that in the end it reaches 10,000 hit´s a second- but that depends more on how the flash player is limited- and if it can perform it.

    otherwise try it yourself ,- setup a Interval wich calls every 10,000 times a second a function wich increases a variable.

    but this is rather a very wacky idea,- better try finding a different approach

  6. #6
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,836
    Flash is limited to 120fps.
    .

  7. #7
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    thinking again,-
    damn 1000 ms as 1s is quite excactly,- if you even try for the nano seconds people might blame the timing on their hardware (keyboard, mouse, cable,...).
    Did you created some tests that can varify that so many people get the excact same ms time

  8. #8
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    yeah, i don't see any problem with milliseconds
    lather yourself up with soap - soap arcade

  9. #9
    Knows where you live
    Join Date
    Oct 2004
    Posts
    944
    As I said before, flash may be rounding to the nearest frame. That is the only real reason I can see why results may be consistant.
    The greatest pleasure in life is doing what people say you cannot do.
    - Walter Bagehot
    The height of cleverness is to be able to conceal it.
    - Francois de La Rochefoucauld

  10. #10
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    if you use the time object or the getTimer(); then it should have to do nothing with frames at all,- not even the framerate. At least the time object or the getTimer is accurate up to it´s miliseconds.
    example:
    Code:
    var time = getTimer();//start event time
    myButton.onPress = function(){
        trace("time delay: "+(getTimer()-time)+" ms");
    }

  11. #11
    SaphuA SaphuA's Avatar
    Join Date
    Oct 2002
    Location
    The Netherlands
    Posts
    2,180
    But the event which is only called "on a frame" will make it inacurate.

  12. #12
    Filthy Gorgeous DancingOctopus's Avatar
    Join Date
    Sep 2003
    Location
    Sunny Australia.
    Posts
    477
    Quote Originally Posted by SaphuA
    But the event which is only called "on a frame" will make it inacurate.
    Could you use setInterval? I'm a bit rusty, so I'm not sure exactly how accurate it is.

  13. #13
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    Quote Originally Posted by SaphuA
    But the event which is only called "on a frame" will make it inacurate.
    but that shouldn´t go for buttons or?,- don´t know how his game works but if he uses buttons for the interaction I see no problems.
    If it is about motion´s try predicting them with calculations and not putting them in a onEnterFrame event just waiting to catch the timing on whatever.

  14. #14
    Software Developer mickm's Avatar
    Join Date
    Sep 2006
    Location
    Kingston [ON]
    Posts
    115
    Thanks for all the replies.

    As for the tests, yes people were able to get the same results here at work very easily, thus I needed something smaller (nanoseconds).

    Anyway the game is as follows (simple);
    1. User clicks their mouse to start the game.
    2. User than has to wait until a red light turns green (random wait time 5 seconds - 10 seconds).
    3. User must then click on the light to stop the timing. (Movie clip with a Mouse Event).

    In most cases people were able to get the same time, or an avg of the same time.

    I may change the game so that the user will not see the "light" at the beginning and then it will appear in a random play on your screen (thus you would have to move your mouse).
    Post you game for free at Gamestack.org. We send the user straight to your website, no iFrames or other leeching methods.

    Please check out Gamestack.org for more information.

  15. #15
    Style Through Simplicity alillm's Avatar
    Join Date
    Mar 2004
    Location
    Wales
    Posts
    1,988
    I was actually having a strange problem the other day where the number of milliseconds in a speed test I was doing was either 0 or 10, but never anything in-between as if flash was rounding to the nearest 10 milliseconds. Maybe something like that is happening to you?

    Ali

  16. #16
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    3. User must then click on the light to stop the timing. (Movie clip with a Mouse Event).
    not sure but try something like this:
    Code:
    myMc.useHandCursor = false;
    myMc.onPress = function(){
       //timer stuff....
    }
    hopefully that is different and wont depend on the framerate

  17. #17
    Software Developer mickm's Avatar
    Join Date
    Sep 2006
    Location
    Kingston [ON]
    Posts
    115
    Renderhjs,

    Thats basically what I am doing right now

    I am changing the game a little bit so people wont be able to get the same time.

    Thanks for everyone's help. Ill post a link of the game when I am done.
    Post you game for free at Gamestack.org. We send the user straight to your website, no iFrames or other leeching methods.

    Please check out Gamestack.org for more information.

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