Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Senior Coder jcdevelopment's Avatar
    Join Date
    Oct 2007
    Location
    Cowboy Nation
    Posts
    2,182
    Thanks
    174
    Thanked 257 Times in 257 Posts

    A Flash timing question!!

    How can i get a timer to when after 10 seconds or more it will move to the next frame. I know there are ways to do this i have seen it before. If anyone has suggestion or a web site that would help.

    Thank you for any suggestions!

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You will want to create a function that calls gotoAndStop(framenumber). You then want to call this function using setInterval(this,"functionname()",10000);

    I've found that anything smaller than 1 second creates an overhead and causes high cpu usage.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    jcdevelopment (01-18-2008)

  • #3
    Senior Coder jcdevelopment's Avatar
    Join Date
    Oct 2007
    Location
    Cowboy Nation
    Posts
    2,182
    Thanks
    174
    Thanked 257 Times in 257 Posts
    Ok i get what your saying the only problem is that i am kinda new to Flash, so do i write a function like i would write a JS function?

    ok i got it, i believe i figured it out, thank you for your help; this is what i used:

    Code:
    Time = setInterval(switchFrame,10000);
    
    function switchFrame():Void {
          if(_currentframe<_totalframes) {
                gotoAndStop(6);
          } else {
                gotoAndStop(1);
          }
          clearInterval(Time);
    }
    
    stop();
    Last edited by jcdevelopment; 01-18-2008 at 06:32 PM.

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You don't really want to clear the interval because then it won't keep rotating. To keep it continously rotating just don't clear the interval. Look into the setInterval syntax again. What I posted is what I used and it works. Don't know if yours will work or not. Yes you are correct on how to write the function. You don't really need the void part there.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    Senior Coder jcdevelopment's Avatar
    Join Date
    Oct 2007
    Location
    Cowboy Nation
    Posts
    2,182
    Thanks
    174
    Thanked 257 Times in 257 Posts
    it, works, but you are right i dont need to clear the interval, thankyou!!

  • #6
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I was assuming you were just calling all of your actionscript from one frame. I see that this may not be the case in which point I would use setTimeout instead because setInterval will keep being called and it might cause overhead. So with that said try this instead
    Code:
    Time = setTimeout(switchFrame,10000);
    
    function switchFrame():Void {
          if(_currentframe<_totalframes) {
                gotoAndStop(6);
          } else {
                gotoAndStop(1);
          }
    }
    
    stop();
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

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