A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: cleartimeout and read the ms left over before its stopped

  1. #1
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404

    cleartimeout and read the ms left over before its stopped

    Hi, I don't think as3 has this right, I wanted to clear my timeout and see the ms left so I can set a users ping based on when he should have arrived between the server/client

    var myTimeout = setTimeout(trace,1100,"hey");

    //lets say I clear timeout in "1000ms, I want to see there is 100ms left over"
    clearTimeout(myTimeout);

  2. #2
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834
    I think that you have to use a separate timer. All I'm seeing is starting and stopping the timeout. Get Timer
    .

  3. #3
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    no only something from settimeout

  4. #4
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834
    If you look at adobe's docs for settimeout https://help.adobe.com/en_US/FlashPl...l#setTimeout(). There's no method for what you want. That's why I said you'd need something extra.
    .

  5. #5
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    As swak says there is no method purely using set time out.
    You need to use get timer too.

    So use two number or int vars. One when you call the timer and one when you stop it.

    Then subtract the first from the second and format the ms into readable time format.

    Fractions of seconds basically. Unless you want the answer in ms. A true second in ms is actually1024ms and not 1000.

  6. #6
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    I feel like that other timer might be heavy though, running at all times and such

  7. #7
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Get timer is running from the very beginning of opening any swf. You just access the time when required

    Ignore my 1024ms thing. Had other things on my plate

  8. #8
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    its always off by some ms it gives different answers based on cpu load I think, 1100ms-1000ms = 32ms left over sometimes changes around that

  9. #9
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    I think you just answered yourself. Of course things will vary with different CPUs and hardware etc etc

    Perhaps avoid the set timeout just call get timer to start and get timer to finish.

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