Actionscript 2 - stop a function

I have a function to make a number count up tp sixty. I want it so if you leave the frame the counter will reinitiate on return. As it is, the counter works fine the first time through, but runs faster everytime you return to frame. Here is the code.
textValue = 10;
addValue = 1;
txt_ET.text = textValue;
function countUp(){
  clearInterval(Interval);
if (textValue < 60){
clearInterval(Interval);
textValue += addValue;
txt_ET.text = textValue;
setInterval(countUp,800);

You should look in the help documentation regarding the use of setInterval and clearInterval to learn how they work. 
If you want to clear an interval you need something to identify the interval.   When the setInterval function executes, it returns a Number value that is such an identifier.  You use that number in the clearInterval function call.  So for what you show above, your setInveral line should look something like...
   var Interval:Number = setInterval(countUp, 800);
then your clearInterval function call as shown should work... except you have a redundant calling of it within the function... one of the two shown is unnecessary - I would guess the first...
   function countUp(){
      clearInterval(Interval);
      if (textValue < 60){
           clearInterval(Interval);

Similar Messages

  • How Do You Stop a Function (k)

    I have this code placed in the second frame of my timeline.
    It is there
    to pause the playhead for 4 seconds before moving onto the
    next frame.
    Problem with the code is that once the statement is true it
    keeps
    jumping ahead doing a perpetual nextFrame.
    I want to reset the variables and stop the function. I have
    no idea what
    I am doing.
    startTime = getTimer();
    trace("startTime "+startTime);
    this.onEnterFrame = function() {
    currentTime = getTimer();
    //4000 below = 4 seconds
    if (currentTime-startTime>4000) {
    nextFrame();
    trace("currentTime "+currentTime);

    Figured it out:
    stop();
    startTime = getTimer();
    this.onEnterFrame = function() {
    currentTime = getTimer();
    //4000 below = 4 seconds
    if (currentTime-startTime>4000) {
    nextFrame();
    this.onEnterFrame = null;
    W. Kirk Lutz wrote:
    > I have this code placed in the second frame of my
    timeline. It is there
    > to pause the playhead for 4 seconds before moving onto
    the next frame.
    >
    > Problem with the code is that once the statement is true
    it keeps
    > jumping ahead doing a perpetual nextFrame.
    >
    > I want to reset the variables and stop the function. I
    have no idea what
    > I am doing.
    >
    > //
    > startTime = getTimer();
    > trace("startTime "+startTime);
    > this.onEnterFrame = function() {
    > currentTime = getTimer();
    > //4000 below = 4 seconds
    > if (currentTime-startTime>4000) {
    > nextFrame();
    > trace("currentTime "+currentTime);
    > }
    > };

  • Stopping a function

    Is there any way to stop a function?
    I have an event listener that is a function "onRollover1".
    I have a second event listener that is a function
    "onStageLeave1".
    Is there a way to put some code into the "onStageLeave1"
    function, to stop the "onRollover1" function?
    In flash 9 there was no problem if the "onRollover1" function
    didn't complete before the "onStageLeave1" function started. The
    code worked fine. But ever since upgrading to CS3, there is a
    glitch, in which causes undesirable effects.
    http://demo.xennsoft.com/assets/menu.html
    Any help would be great! Thanks in advance :)

    the problem appears to be that there are two Tweens acting on
    the same object at the same time, conflicting with each other.
    First thing to do would be to set up a global variable for the
    tween rather than a local variable. then you can refer to the tween
    later, and tell it to stop before starting a new tween on the same
    object.

  • Can I stop the function of button SHIFT

    HI every one
    I want stop the function of button SHIFT in keyboard
    how this in form?
    another question
    I want when I press F1 ==> save the form instead of F10
    THANX ALOT

    hi
    For shift its not possible but for F1 its.
    D:\DevSuiteHome_1\forms
    open the following files in NotePad.And make a backup for u r files before changes.
    Fmrpcweb.res
    and
    Fmrweb.res
    sarah

  • Stop a function module

    Hello,
    I have a fuction module and I will export errors. When I export an error, the function module must stop. How can I stop the function module after the error message? Can I use exit?

    I don't use exceptions. In my function module I have some subroutines. In this subroutines are the error messages. When I use exit it don't stop? What can I do?
    For example:
    FORM XY CHANGING MSGERROR TYPE BAPIRETURN.
    IF NOT XX <> ''.
       error-type = 'W'.
       error-message = 'Error'(001).
       exit.
      ENDIF.
    ENDFORM.

  • Stop watch function in N79

    I fail to find stop watch function in N79. Do I need to install it? If yes, how and from where? Please help. Thanks.
    Solved!
    Go to Solution.

    Many thanks for your help. I use the stopwatch and countdown timer at at work and also sometimes when Cooking!
    Does anybody know why Nokia decided to not include this feature? I would have thought this is now become a basic feature of a Mobile. I also used to use it to time xtra time when watching my team, Bury FC. I have bought a timer from the Ovi store but its not very good and seems to use a lot of battery power. I'm sure if Nokia design and create a timer and stopwatch it would be as good as in previous mobiles, being more integrated into the phone. Just my thoughts on what is otherwise a very good phone.

  • Actionscript to Stop Clock

    I have created a Clock in flash using the following
    actionscript:
    time=new Date(); // time object
    seconds = time.getSeconds()
    minutes = time.getMinutes()
    hours = time.getHours()
    hours = hours + (minutes/60);
    seconds = seconds*6;
    minutes = minutes*6;
    hours = hours*30;
    sec._rotation=seconds;
    min._rotation=minutes;
    hour._rotation=hours;
    What I need help with is I want the clock to stop when the
    time reaches 11h 11min and 11sec.
    What code would I need to use?
    Any help would be appreciated.

    Ok, i used another online tutorial to create an antique style
    clock but I am still having difficulty using code to make it stop.
    Is there code I can use to specify the time I want the Movie to
    stop playing or is there code I can use so by pressing a hotkey it
    will stop the Movie?
    Here is the code I am using:
    clock.onEnterFrame = function():Void {
    var clockTime:Date = new Date();
    var seconds:Number = clockTime.getSeconds();
    var minutes:Number = clockTime.getMinutes();
    var hours:Number = clockTime.getHours();
    this.secondHand._rotation = seconds*6;
    this.minuteHand._rotation = minutes*6;
    this.hourHand._rotation = (hours*30)+(minutes/2);
    }

  • Stopping previous functions and tweens onPress

    Flash newbie.  Trying to see if someone can guide me to a way I could stop my earlier tweens and onRollOver function when my onPress function is launched.  What I worked out here with that McX/YScale.stop(); and that target9_mc.onRollOver = null; is kind of working but I don't want the onRollOver function to stop until the onPress function begins. Really appreciate any help.  Thanks.
    var mcl_obj9:Object = new Object();
    mcl_obj9.onLoadInit = function(target9_mc:MovieClip) {
    target9_mc._x = 410;
    target9_mc._y = 10;
    TransitionManager.start(target9_mc,{type:Fly, direction:Transition.IN, duration:1, easing:Elastic.easeInOut, startPoint:6});
    var ogYScale = target9_mc._yscale;
    var ogXScale = target9_mc._xscale;
    new mx.transitions.Tween(target9_mc, "_xscale", mx.transitions.easing.Strong.easeOut, ogXScale, ogXScale-38, 30, false);
    new mx.transitions.Tween(target9_mc, "_yscale", mx.transitions.easing.Strong.easeOut, ogYScale, ogYScale-38, 30, false);
    target9_mc.onRollOver = function():Void  {
    var mcXScale:Tween = new Tween(target9_mc, "_xscale", Elastic.easeOut, 60, 64, 4, true);
    var mcYScale:Tween = new Tween(target9_mc, "_yscale", Elastic.easeOut, 60, 64, 4, true);
    mcXScale.stop();
    mcYScale.stop();
    target9_mc.onPress = function():Void {
    target9_mc.onRollOver = null;
    target9_mc._y += 5;
    target9_mc._x += 5;
    target9_mc._xscale += 5;
    target9_mc._yscale += 5;
            if (target9_mc._x >= 300) {
        target9_mc._x = 475;
    if (target9_mc._y >= -1) {
        target9_mc._y = 40;
    if (target9_mc._xscale <= 150) {
        target9_mc._xscale = 200;
    if (target9_mc._yscale <= 150) {
        target9_mc._yscale = 200;
    var my_mcl9:MovieClipLoader = new MovieClipLoader();
    my_mcl9.addListener(mcl_obj9);
    my_mcl9.loadClip("bottlebuild9.png",this.createEmptyMovieClip("img9_mc", this.getNextHighestDepth()));

    you can use:
    var mcl_obj9:Object = new Object();
    mcl_obj9.onLoadInit = function(target9_mc:MovieClip) {
    target9_mc._x = 410;
    target9_mc._y = 10;
    TransitionManager.start(target9_mc,{type:Fly, direction:Transition.IN, duration:1, easing:Elastic.easeInOut, startPoint:6});
    var ogYScale = target9_mc._yscale;
    var ogXScale = target9_mc._xscale;
    new mx.transitions.Tween(target9_mc, "_xscale", mx.transitions.easing.Strong.easeOut, ogXScale, ogXScale-38, 30, false);
    new mx.transitions.Tween(target9_mc, "_yscale", mx.transitions.easing.Strong.easeOut, ogYScale, ogYScale-38, 30, false);
    var mcXScale:Tween
    var mcYScale:Tween
    target9_mc.onRollOver = function():Void  {
    mcXScale = new Tween(target9_mc, "_xscale", Elastic.easeOut, 60, 64, 4, true);
      mcYScale = new Tween(target9_mc, "_yscale", Elastic.easeOut, 60, 64, 4, true);
    mcXScale.stop();
    mcYScale.stop();
    target9_mc.onPress = function():Void {
    mcXScale.stop();
    mcYScale.stop();
    target9_mc.onRollOver = null;
    target9_mc._y += 5;
    target9_mc._x += 5;
    target9_mc._xscale += 5;
    target9_mc._yscale += 5;
            if (target9_mc._x >= 300) {
        target9_mc._x = 475;
    if (target9_mc._y >= -1) {
        target9_mc._y = 40;
    if (target9_mc._xscale <= 150) {
        target9_mc._xscale = 200;
    if (target9_mc._yscale <= 150) {
        target9_mc._yscale = 200;
    var my_mcl9:MovieClipLoader = new MovieClipLoader();
    my_mcl9.addListener(mcl_obj9);
    my_mcl9.loadClip("bottlebuild9.png",this.createEmptyMovieClip("img9_mc", this.getNextHighestDepth()));

  • How to stop the function if Validation is fail

    Hello guys
       Got an easy question. I am trying to validate the users inputs to see if they enter the values for my textInput. The validator instance is binded to the button click. If the user clicks the button without entering value, the error messages will pop up, if they enter the values then click the button, the application will process the click event handler. My question is when the user clicks the button without the input information, my handler still process the code, and give me runtime error because the textInput is empty. I know I could use conditional statement to prevent this, but I was wondering if there are any ways to stop the handler by USING VALIDATOR class. Thanks for any helps.
    code
    AS:
    protected function insert_clickHandler(event:MouseEvent):void
    //do something here if the name if not empty.....I thought the validator will stop the application if the validation is fail.....am I wrong?
    mxml
    <mx:StringValidator id="cityValid" source="{name}"
    property="text" trigger="{add}"
    triggerEvent="click.add"  //only trigger when click on add state.....
    required="true"/>

    Sorry for the confusion. the triggerEvent="click.add" should be triggerEvent.add="click"
    I am using Flex 4. The validation is fail if the user don't input anything. Does clickHandler still process the code even though the validation is fail?

  • Debugger Stopping on Function with No Errors

    My code is at the bottom.
    The debugger always stops on the getViewResults() function.
    As you can see, I've created two date objects that are being passed
    into the function as arguments.
    Can anyone see from the code what may be causing the debugger
    to stop on that line without any errors?
    Thanks.
    private function getData(event:MouseEvent):void
    var date1:Date = new Date(0001, 1, 1, 12, 0, 0, 0);
    var date2:Date = new Date(9999, 1, 31, 23, 59, 59, 9999999);
    emkw.getWebService().addSimpleHeader("Header1","https://www.mydata.com/DataService/Data.a smx","testName","testValue");
    emkw.getWebService().addHeader(header1);
    emkw.addgetViewResultsEventListener(resultHandler);
    trace("GOT DATA");
    emkw.getViewResults("Patient
    Conditions",date1,date2,null,null,0,0);
    }

    "phillipus_rex" <[email protected]> wrote in
    message
    news:go6fm2$je4$[email protected]..
    > My code is at the bottom.
    >
    > The debugger always stops on the getViewResults()
    function. As you can
    > see,
    > I've created two date objects that are being passed into
    the function as
    > arguments.
    >
    > Can anyone see from the code what may be causing the
    debugger to stop on
    > that
    > line without any errors?
    Is there a blue dot next to the line number in the code
    window?

  • Stop Fax functionality for some buyer codes.

    Hello Everyone,
    We need to stop faxing for certain buyer codes in SRM. Because some buyers are retired and we do not want to fax the POs under their buyer codes.
    Because we run the L7A and L6G programe and it sends all the purchase orders to faxing. We want to stop the faxing of these POs while these programs are running and once these programs are complete we want to turn on the Fax functionality.
    Can somebody help me in this?
    Thanks,
    Khushbu.

    in MN05 you can maintain for which messagetype of the and vendor you want to use mail instead of fax
    When you have a messagetype in de PO like ZXXX for sending the fax then you can also set it to email in MN05 for specific vendors. (in customising mail must also be active for ZXXX ofcourse)
    kind regards
    arthur
    Edited by: A. de Smidt on Jan 4, 2011 3:50 PM

  • How to stop trigger function when in post query?

    Hi All,
    I have a problem, not able to find the solution.
    I have created a form with 10 field items.
    For a field item called RECEIVED_15G, i have created a trigger:WHEN-VALIDATE-ITEM, it works fine as per my requirement.
    The problem is that i want this trigger to work only when i run the form , that when system is in NORMAL mode.
    I don't want this trigger to work after i do execute query, even here the system is in NORMAL mode.
    So how do i make it to work ??
    Is it possible to stop that trigger work after i click execute query (Something that i can code in Post query) ??
    Help me . Thank You.
    Oracle Forms 6i,
    Oracle DB 9i.

    Hi
    pls share with us the code my guess ; the When-Validate-Item (WVI) trigger is firing because you are setting a value in an item from post-Query Trigger>
    Note: just assign a name in a display item in post-query trigger DONT assign an id or any db item.
    Amatu Allah

  • How to end (stop) this function

    Hi all,
    using this function to play a scene for 23 seconds after
    which the movie moves on
    to another scene - trouble is, every 23 seconds it happend
    again !
    Need a way to make the function work once and then never
    again.
    Help much appreciated
    Best wishes
    Tony
    loadMovieNum("matrix.swf", 2);
    function wait() {
    unloadMovieNum(2);
    gotoAndPlay("Scene 2", 1);
    myTimer = setInterval(wait, 23000);

    Try using setTimeout() instead.

  • Actionscript is stopping my Tweening. Is there an override?

    Hi Everybody,
    I'm importing/assigning values dynamically using XML and everything's working fine...
    ...until the timeline reaches a tween for the same object and it fails to animate.
    Is there a way I can kill/override the AS2 assignment to the object and have it listen back to the timeline?
    Thanks for any suggestions!

    you can't mix timeline tweening with actionscript that affects the timeline-tweened property.
    ie, use one (actionscript) or the other (the timeline).

  • My i-pad has stopped. wont function, move, anything? It is locked on my FACEBOOK page, but no movement.???

    I moved to the facebook button, pushed it and now the I-Pad is locked in the on position...wl not turn off, nothing. How do I unlock it? Earl

    If the reset doesn't work like tonefox suggests and the Facebook page is still loaded on the iPad, see if you can force quit the app. Hold down on the sleep button until the red slider appears but do not slide to shut down. let go of the sleep button and then hold down on the home button until Facebook quits. Then restart the iPad by holding down on the sleep button until the red slider appears but this time slide to shut down. Hold down on the sleep button again until the Apple logo appears - let go of the button - let the iPad finish restarting.

Maybe you are looking for

  • IPod no longer connects to computer

    Don't know what happened. If I plug my iPod in to charge using one of those cube chargers it works, but when I plug it in to my computer it won't bring it up on Finder and iTunes doesn't automatically run. Don't know what to do, wondering if I have t

  • Migrating Library From Old External Drive To New External Drive - How?

    So my current external drive is filled to the max so I need to buy a new one. I have a lot of playlists (representing albums) but if I get a new hard drive, will the playlists and their contents be linked to the music correctly? If not, how am able t

  • Web pages in Oracle Application 12.0.6

    Hello every one.. i am having a one problem.. i want to create the SSHR LOGGING report.. in which i want to show the list of employees how have visited the application... this is the following query : SELECT p.employee_number employee_number, p.first

  • A016 is not updating in SAP

    Dear SAP Exprts, Please suggest me Table A016 is not updating, Is the reason of Client settings or any debug in SAP? Please request to ans my qtn. Regards TG

  • Safari 5.1.2 will not install

    Downloaded Safari 5.1.2 from the Apple web sit, running OS X.7.2 on a Quad Core Mac Pro. Software will not install.  On installation window reads "Waiting for other installations to complete".  Does not compete nor install after 30 mintes. No other p