SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru
    Join Date
    Nov 2001
    Location
    Fort Lauderdale
    Posts
    814
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is this method of using setInterval CPU intensive?

    I have 10 movie symbols on the stage at the same time. In each symbol I have the following code:

    Code Actionscript:
    stop();
    pause = function () {
            play();
            clearInterval(pausei);
    }
    pausei = setInterval(pause, 5000);

    All it does is repeat an animation in each symbol.

    I used the above method because I figured it would keep the .SWF file size small, since i wouldn't be adding unneeded frames so the animations wouldn't repeat so quickly.

    However I'm not sure how CPU intensive the above code would be since it's running 10 times. Sure saving filesize is great, but not if i crash a users computer lol.

    Can anyone please advise me?

    - What im trying to do is repeat the animations in the movie symbols but after a specific amount of time. So basically... Play the movie, Pause a few seconds, Then play the animation again, Then Repeat.

  2. #2
    SitePoint Wizard jim_morrison3's Avatar
    Join Date
    Apr 2004
    Location
    UK
    Posts
    2,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    setInterval is CPU intensive, also if you use lots of setInterval methods then its hard to control them even by using clearInterval method.
    Good Luck!
    There are things known and Things unknown
    And in between are the Doors.
    I love hand Coding.

  3. #3
    SitePoint Guru
    Join Date
    Nov 2001
    Location
    Fort Lauderdale
    Posts
    814
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your reply.

    So would it be better to just create the extra frames, although the filesize will increase?

  4. #4
    SitePoint Wizard jim_morrison3's Avatar
    Join Date
    Apr 2004
    Location
    UK
    Posts
    2,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can also use onEnterFrame event with getTimer() method.
    Good Luck!
    There are things known and Things unknown
    And in between are the Doors.
    I love hand Coding.

  5. #5
    SitePoint Guru
    Join Date
    Nov 2001
    Location
    Fort Lauderdale
    Posts
    814
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jim_morrison3 View Post
    You can also use onEnterFrame event with getTimer() method.
    Never heard of getTimer(), i will look into it. So this method isn't as CPU intensive?

    Thank you very much.

  6. #6
    SitePoint Wizard Rabies's Avatar
    Join Date
    Apr 2005
    Posts
    1,515
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 4SeeN View Post
    Thank you for your reply.

    So would it be better to just create the extra frames, although the filesize will increase?
    I'd agree with this method. Filesize won't increase noticably.

    The only downside is that the duration of the pause won't be accurate. Say you have 30 blank frames and your frame rate is 30 frames per second, then this pause will be 1 second long, but only if the flash is actually playing at 30 fps. If its being viewed on a slow computer, the pause through animation frames will be longer.


Bookmarks

Posting Permissions

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