Flash Advisor logo
:: Desktop Shortcut
:: Flash Help
Advice from Experts

Closed Thread
Results 1 to 4 of 4

Thread: countdown timer

  1. #1

    Default countdown timer

    hi, i am trying to use a countdown timer on my game....it should count down from 100 to 0 and on reaching 0 it should end and go to the incorrect page.

    i dont know how to implement this, do you have any idea? a text box to coundown from 100 to 0 and on the end it uses GOTO to go to a different layer..

  2. # ADS
    Join Date
    Always
    Posts
    Many
     
  3. #2

    Default moving from the scene.....

    Hi i also cant get this to work for different parts of the scene. When i change it for another part for exmple ("scene 1" , 25) it changes it for every other part of the scene where i am using this code but dont want it to go to ("scene 1" , 25) but instead for example ("scene 1" , 40)




    if ((Number(/:sec) == 0)) {
    tellTarget ("level0") {
    gotoAndStop ("Scene 1", 25);
    }
    }

  4. #3
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,

    Targeting scene names is a bad habit in flash. Actually, I dont use scenes...

    http://ntdesigns.net/v-web/bulletin/...wtopic.php?t=8

    It is much better to use frame labels and target those instead. Place a frame label on the frame that you want to send the flash playhead to and use that frame label in the button code....
    Code:
    on (release) {
    _root.gotoAndPlay('frameLabel');
    }
    As for the countdown timer, there are multiple ways to do this. One method is using a movieclip timeline as a counter. You can use the frames per second that plays a flash movie as a counter. For example, a movieclip with 48 frames, each with a count variable on frames 12,24,36, and 48, would give you the ability to count from 1 to 4 seconds. On each of those frames, something like....
    frame 12
    _root.myCount = 1;
    frame 24
    _root.myCount = 2;
    frame 36
    _root.myCount = 3;
    frame 48
    _root.myCount = 4;

    Then on the main timeline, a textfield with an instance name 'counter'. On the first frame of the movie..

    _root.textFieldName.text = myCount.

    Another method could be with actionscript. Two command options,..... setInterval and getTimer............ setInterval is prob more adapt at creating events on an interval basis, so lets look at getTimer......

    If we created a variable, say..... countTotal = 100; We could use getTimer to countdown from that variable.....
    Code:
    countTotal = 100;
    _root.onEnterFrame=function() {
    //getTimer returns milliseconds so we divide by 1000
    now = getTimer()/1000;
    _root.textFieldName.text = countTotal - now;
    }
    All untested code off the top of my head. If it doesn't work for you, post a demo file.

    Hope it helps
    NTD
    A mind once stretched by a new idea never regains its original dimensions.
    - Oliver Wendell Holmes

  5. #4

    Default in mins and seconds?

    this work fine. I just need to know how do I make flash display in mins and seconds. instead of seconds.

    let's say: for 100 seconds. instead of displaying 100, 99, 98

    I wanna do this : 1:40, 1.39, 1.38. etc

    How do i further modify the code to do the above. countdown in mins and seconds?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Countdown timer.. in flash 8
    By mattleeds in forum Games
    Replies: 1
    Last Post: 11-04-2006, 08:51 AM
  2. Scripting Countdown Timer
    By Lelock1 in forum Advanced Flash
    Replies: 2
    Last Post: 09-30-2006, 07:18 PM
  3. Countdown script
    By tomleadbetter in forum Flash Scripting
    Replies: 0
    Last Post: 07-28-2006, 12:57 PM
  4. count up in timer?
    By bluereo in forum Flash Scripting
    Replies: 1
    Last Post: 06-17-2005, 07:34 PM
  5. Simple Countdown Timer, help.
    By FF7fan in forum Newbies
    Replies: 1
    Last Post: 04-14-2005, 01:43 AM

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
Sponsors
Create Speaking Characters for your website and Flash movies. 15 Day Free Trial