A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: set Interval problem

  1. #1
    Senior Member
    Join Date
    Feb 2003
    Location
    England
    Posts
    136

    set Interval problem

    hey i have this block of code:

    setInterval(function () {
    angle += 0.045;
    _parent.clock.back.arm._rotation = angle;
    timer = i;
    }, 1);

    it moves an arm on a clock very smoothly, works fine in a SWF but runs far too slowly when in a browser, any ideas would help alot. im lost..

    cheers
    Looking for a young enthusiastic new media developer? Look no further than… www.2dworld.com

  2. #2
    Senior Member
    Join Date
    May 2001
    Posts
    1,838
    Make its rotation change 0.25 degree per 5 msec.

    I believe 0.25 degree is the unit that Flash handles rotation.

  3. #3
    Senior Member
    Join Date
    Feb 2003
    Location
    England
    Posts
    136
    no matter what settings i use it always runs too fast in the broswer.. could it be that set intercal uses cpu speed to work and the cpu is under pressure therefore slower?

    http://www.2dworld.com/corp/countdownclock.swf

    this is the arm moving 6 degrees every second, not ideal bu this way it keeps the time perfectly.. why not so if i use .00 numbers..?
    Looking for a young enthusiastic new media developer? Look no further than… www.2dworld.com

  4. #4
    Senior Member
    Join Date
    May 2001
    Posts
    1,838
    Oh, that is what you mean by "slow" !

    Both setInterval and onEnterFrame are not evoked at precisely accurate interval. A movie with FPS 12 is not going to be played acurately for one frame per 83.3333333333333 msec;

    Yes, the interval is partly affected by the working load of CPU.

    If you want to make a clock, you get to peek the system clock.

  5. #5
    Senior Member
    Join Date
    Feb 2003
    Location
    England
    Posts
    136
    so why does it run fine in a swf on its own when in a broswer it runs too slow? does the broswer have to keep up with the timing of the swf?
    Looking for a young enthusiastic new media developer? Look no further than… www.2dworld.com

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