7 Replies Latest reply on Mar 30, 2007 5:03 PM by kglad

    Countdown Poker Timer in Flash 5

    Wide Open Mike Level 1
      Yeah, I'm behind with Flash 5. Haven't used it in a long time but I'm now waiting for CS3 so I can get all the upgrades...

      I've been all over the web and found a few tutorials on making timers. Some I've gotten to work, other not so much luck. The problem is all the tutorials I've seen tend to be more in depth than I think I need. I'm trying to make a poker timer for the blinds that I can run on my laptop during tournaments.

      I want to be able to launch my SWF onscreen and it should ask me an interval. Typically this will be 15 minutes but could change. When the start button is pressed that variable, I'll call it "TimerInterval", will be passed to the timer movie clip and the blinders movie clip should progress to show the current blinds. After 15 minutes is up it should stop. When the start button is pressed again the timer starts again and the movie progresses to the next blind level. I will also need the ability to pause the timer and skip or go back frames (blind levels).

      So what I'll have is a movie with the timer movie clip in it and another movie clip with the blind amounts. Hitting the start button in the main movie starts the timer movie clip and advances the blinds movie clip to the next frame, which will just be a static block of text.

      Hopefully, that all makes sense.

      So, I think I've got a pretty good grasp on what I need to do with the controls but the timer is still a mystery to me. All I need is minutes:seconds and maybe milliseconds (just 'cause it looks cool) counting down from TimerInterval to 0. I would however like to keep the minutes, seconds, and milliseconds as separate entities so I can keep the numbers from jumping around due to number width (1 is thinner than 8 so the text jumps to the left).

      So, like I said, all the tutorials I've found use the Date() function to countdown to another specific date and I don't know how that will work with my situation. I did see one that used a Timer() function but can't seem to locate that bookmark.

      I do have some script I used for a different site for a slideshow type of thing where I had:
      Frame 1
      currently = getTimer();
      end = currently + 3000;
      Frame 2
      currently = getTimer();
      Frame 3
      if (currently <= end) {
      gotoAndPlay ("Timer2");
      }

      which I might be able to adapt but there is no visual display associated with this script.

      Anyone got some ActionScript laying around that will work or an easy way to adapt the above script to output the time counting down backwards?

      Thank you,

      Mike
        • 2. Re: Countdown Poker Timer in Flash 5
          Wide Open Mike Level 1
          Thanks. I think I've seen that before here... I think that needs to go in the main timeline with the Dynamic Text in the main timeline as well. Right now I've made another MC with both in it so I haven't gotten it to work but I'm running into other simpler problems that I'd love to solve first.

          I've got my Previous and Next buttons in a MC called ButtonsMovie in the main timeline. When it hit either I'm trying to make the MC BlindProgression, also in the main timeline, go to the previous or next frame. I'm using:

          on (release) {_root.BlindProgression.nextFrame();}

          Isn't that correct? When I put the button in the BlindProgression MC and just say

          on (release) {.nextFrame();}

          it works...

          Sorry, I haven't touched Flash in probably two years so I'm really rusty...
          • 3. Re: Countdown Poker Timer in Flash 5
            kglad Adobe Community Professional & MVP
            that code can go anywhere. you just need to use the correct path to timerF() and to your displayTF.

            your code is correct if BlindProgression is on the _root timeline. because it's not working you can infer that BlindProgression is not on the _root timeline. check spelling and case of BlindProgression.
            • 4. Re: Countdown Poker Timer in Flash 5
              Wide Open Mike Level 1
              Man, told you I was rusty... I had the MC called BlindProgression (as it's called in the Library) on the timeline but I forgot to give it the Instance Name of BlindProgression... (that problem solved)

              So I've got two frames in my _root movie.
              1 has all the images, MC BlindProgression, MC ButtonMovie, and Dynamic Text displayTF. It also has a stop(); action.
              2 has everything above with a stop(); action and your script.

              In frame 1 I have a MC with the START button on it. I have on (release) {_root.nextFrame();} assigned to it so that it should advance the _root to the next frame with the script and execute it.

              Am I needing to call that script in another manner besides just entering the frame? I'm sure I'm missing something pretty simple here...
              • 5. Re: Countdown Poker Timer in Flash 5
                kglad Adobe Community Professional & MVP
                displayTF just needs to continue to exist in frame 2.

                oops, and you need to use correct code (which i didn't supply above):

                • 6. Re: Countdown Poker Timer in Flash 5
                  Wide Open Mike Level 1
                  Hmm... still nothing. I took the first frame and the stop()s out so the action will just run on the first frame but nothing happens.

                  If you have a moment why don't you clue me in as to what's happening in the script? I can figure out most of it but some I'm not sure of. Please correct any of my incorrect assessements below:

                  tl = this; ???
                  function timerF(endTime) defines the function based on timerF defined at the bottom as endTime
                  [btl.onEnterFrame = function() says to start the function when the frame is entered.
                  seconds = String(Math.floor(timeLeft/1000)%60); I'm not sure what the String_Math.floor is doing...
                  delete tl.onEnterFrame; ???
                  startTime = getTimer(); this defines startTime but I don't know what getTimer(); is or how it's defined.

                  Why are the statements at the bottom in that position vs above the whole thing?

                  Thanks for the help...