A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Simple Countdown Timer

  1. #1
    Junior Member
    Join Date
    Apr 2005
    Posts
    11

    Simple Countdown Timer

    I just want to make a simple countdown timer, that everytime the flash movie hits the timers keyframe it counts down from 10 and then plays a sound. Is there a way to do this?

  2. #2
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hi,

    Flash allows for many ways to accomplish the same task. In this case, you could use a movieclip 120 frames long(assuming your movie frame rate is 12 fps), place a number every 12 frames..... 10,9,8,etc,.... then, on the last frame of the movieclip, have a stop action and a sound on the frame.

    Another method might be to use nothing but actionscript to achieve the same effect.Paste this code onto a frame and test, you will need a sound in your library set to export for actionscript with an ID name...

    code:

    _root.createEmptyMovieClip("countDown", 10);
    cCenterX = Stage.width/2;
    cCenterY = Stage.height/2;
    _root.countDown.counter._x = cCenterX;
    _root.countDown.counter._x = cCenterY;
    _root.countDown.createTextField("myTextField", 1, cCenterX, cCenterY, 30, 20);
    _root.countDown.myTextField.background = true;
    _root.countDown.myTextField.autoSize = "center";
    _root.countDown.myTextField.border = true;
    _root.countDown.myTextField.backgroundColor = 0x00FFCC;
    count = 10;
    myCountDown = function () {
    count--;
    };
    countInterval = setInterval(myCountDown, 1000);
    this.onEnterFrame = function() {
    _root.countDown.myTextField.text = count;
    if (count == 0) {
    clearInterval(countInterval);
    _root.countDown.myTextField.text = "00";
    mySound = new Sound();
    mySound.attachSound('soundID');
    mySound.start();
    }
    }


  3. #3
    Junior Member
    Join Date
    Apr 2005
    Posts
    11
    It works now, thanks for the help.

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