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

Closed Thread
Results 1 to 2 of 2
  1. #1

    Lightbulb timer starts but does not stop..please help

    Hi all,

    I am doing a small game in flash in which their is a functionality. However, the script which I got online does not work when placed inside a movie clip. therefore, I made some animation outside in the main frame and start the timer.
    Below is the code which has been used in the actions layer with the 00:00:00:00 with "timer_txt" as the variable name.

    startTime = getTimer();
    onEnterFrame = function () {
    elapsedTime = getTimer()-startTime;elapsedHours = Math.floor(elapsedTime/3600000);
    remaining = elapsedTime-(elapsedHours*3600000);elapsedM = Math.floor(remaining/60000);
    remaining = remaining-(elapsedM*60000);elapsedS = Math.floor(remaining/1000);
    remaining = remaining-(elapsedS*1000);elapsedH = Math.floor(remaining/10);
    if (elapsedHours<10) {hours = "0"+elapsedHours.toString();
    }
    else {hours = elapsedHours.toString();
    }
    if (elapsedM<10) {minutes = "0"+elapsedM.toString();
    }
    else {minutes = elapsedM.toString();
    }
    if (elapsedS<10) {seconds = "0"+elapsedS.toString();
    }
    else {seconds = elapsedS.toString();
    }
    if (elapsedH<10) {hundredths = "0"+elapsedH.toString();
    }
    else {hundredths = elapsedH.toString();
    }
    _root.timer_txt = hours+":"+minutes+":"+seconds+":"+hundredths;
    };

    Now, once the Movieclip starts the timer starts but it also has to stop once this mission is accomplished.

    Can you please help me to get the action script for the stop button which has to pause the digital timer on the main frame and display that it is the final time on the main screen. Please help

    Thanks in advance!!

  2. # ADS
    Join Date
    Always
    Posts
    Many
     
  3. #2
    Join Date
    Aug 2007
    Location
    Germany
    Posts
    390

    Default

    hey

    you need an event when the timer should stop.
    then you can asign the onEnterFrame to the textField, and delet the onEnterFrame when you want to
    Code:
    _root.timer_txt.onEnterFrame = function() {
    
    // Your code for calculating the time here
    };
    and for the event, when the animation is done or the game is over, you need to call
    Code:
     delete _root.timer_txt.onEnterFrame;
    Hope it helps!
    Regards,
    A.
    hardware is the part of a computer which can be kicked

    Things that NTD thaught me:

    {An optimist sees the glass as half full. A pessimest sees the glass as half empty.
    A programmer sees the glass as twice the size it needs to be.}


    Please no questions via private and / or instant message!


Thread Information

Users Browsing this Thread

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

     

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