Stoping a looping animation code at certain time

I am using a code which creates a twinkling star effect. I need to make the effect stop at either 30seconds of itplaying or if possible on a certain frame.
Here is the code I am using:
onClipEvent (enterFrame) {
getTargetAlpha = function(){
          return Math.random() * 100;
this.speed = 9;
this.target = this.getTargetAlpha();
this.onEnterFrame = function(){
          if(this._alpha < this.target){
                    this._alpha += this.speed;
          }else if(this._alpha > this.target){
                    this._alpha -= this.speed;
          }else if(this._alpha == this.target){
                    this.target = this.getTargetAlpha;
Is it possible to apply something to achieve this?

You should get any code "on..." objects off of them and keep it all in the timelline.
You can use the setTimeout() function to take care of timing out at 30 seconds and cancelling whatever other code you have processing.  Look it up in the help documentation or search Google for how to use it.

Similar Messages

  • Cannot pause or preview animation to a certain time point.

    Hello All,
    I have Adobe Captivate 4. I am leaving my work in 2 weeks time and i have been asked to record and talk about the software applications i use for my job.
    I record my application (Autodesk Inventor) and it inserts the full motion preview into the slide. However i want to add highlight boxes, captions, text etc etc. So i use the timeline at the bottom and drag it to the right. As i am dragging it to lets say 20 seconds into the slide the animation (recording) is previwing as its meant to do. But once i release the mouse and leave the point to 20 seconds the animation previews at 0 seconds and no longer 20 seconds. But the red slider is still on 20 seconds (hope i am making sense here).
    Its extremly fustrating because i cant add highlight boxes, text, captions etc because i cant get the animation to preview and stop at a certain time point.
    Anyone know the cause of this?
    I am using Windows 7 64-bit and i have ran the application as administrator.
    Thanks
    Ben

    Hi there
    Perhaps it will help to explain how to exploit what is quite possibly a bug in Captivate.
    Using the technique of scrubbing the playhead (clicking and dragging the playhead on the Timeline) keep the mouse button clicked as you press Alt+Tab to shift focus to another application. (the other application should be running full screen)
    After the other application gains focus, release the mouse button.
    Press Alt+Tab to return to Captivate.
    What you should see at this point is that Captivate should behave as if you paused it. The playhead should be right where you left it with everything in view. You should now be able to insert a Text Caption or other object.
    While I'm aware it's likely not what you were hoping for, perhaps it's better than nothing?
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • Run a section of code a certain time of day

    I have a problem which I am stuggeling to get right.
    At a certain time of the day, the process must run a verification sequence which must be completed.
    I was thinking about using two time values, the one being the actual time and the other being the target time. Once the actual time is equal or more than the target time, some code must run. This code must run (verification sequence) before any other code can run.
    Please any advice would greatly be appreciated

    Lucither wrote:
    Hein,
    This will be true when current time is equal or greater then the set time:
    Rgs,
    Lucither
    The suggestion above are correct in answer the question "how to compare times?" but there is an ancillary question that goes with this challenge that being "What time value do I compare with the current time?"
    Sounds simple at first glance and in most situations is a no-brainer UNLESS your app is a 24X7 365 day never go down app. In that case you have to deal with Daylight savings time (Lets ignore leap years seconds etc for now). With DST, we have to deal with the fact that there is one day with 23 hours and another day with 25 hours. One of those days does not have a "2 O-clock" times and the other has two, one with DST true and another with DST false. The other complication that coes with that fact is that (in the US at least) the dates on which those 23 and 25 hour days occur are defined by the whims of governement ("Those who seek to change times and way.." Is that reveleations?) so you can't code for changes ahead of time.
    If you get past that challenge, the other thing to take note of is that Windows displays the creation date of files in the current time (DST T/F) so a file created at 1:00 last night may have a creation time of 2:00.
    I hope you don't have to deal with DST and if you do, at least you have been warned.
    Ben
    Quoting from here...
    This thing all things devours:
    Birds, beasts, trees, flowers;
    Gnaws iron, bites steel;
    Grinds hard stones to meal;
    Slays king, ruins town,
    And beats high mountain down.
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How to stop a while loop after certain time using Elapsed time vi

    how to stop a while loop after certain time using Elapsed time vi.

    Hi Frankie,
    Just place the Elapsed Time VI inside the WHILE loop, and wire the 'Time Has Elapsed' output to the conditional terminal in the lower right corner (which should be set to 'stop if true' by default).
    In the future, please post your LabVIEW questions to the LabVIEW Forum.  You have a much better chance of getting your questions answered sooner, and those answers can then help others who are searching the LabVIEW forums.  Thanks!
    Justin M
    National Instruments

  • Memory requirement is continiously increased when i am running my application program in an infinite loop,after certain time it shows an error called low virtual memory

    memory requirement is continiously increased when i am running my application program in an infinite loop,after certain time it shows an error called low virtual memory

    What are you doing with your program. Lots of improper programming techniques can cause this - building arrays, concantanating strings, opening but not closing refrences, etc. Need more details or post your VI. Also, have you looked at "LabVIEW Performance and Memory Management"? It's part of the shipping documentation and available from Help>Search the LabVIEW Bookshelf.

  • Mechanism that runs my application only at certain times of the day

    Hi,
    As my title suggests, i'm looking for some code that will allow me to run parts of my application only at a certain time in the day. More specifically, I want the code to run these parts of the application at 5pm only on weekdays.
    I've tried various different types of loops to do this, but can't find anyway to do it.
    Could somebody suggest a better way of doing it?
    Thanks in advance.
    Here is some example code of what I tried:
    public static void main(String[] args)
         // TIMER
         Calendar cal = new GregorianCalendar();
         // Get the components of the time
         int hour24 = cal.get(Calendar.HOUR_OF_DAY); // 0..23
         int min = cal.get(Calendar.MINUTE); // 0..59
         int today = cal.get(Calendar.DAY_OF_WEEK);
         final int RUNH = 17;
         final int RUNM = 0;
         app start = new app(); //starts the application
         while (!((hour24 == RUNH) && (min == RUNM)) || (today ==1 ) || (today == 6))
              // do nothing
         if((hour24 == RUNH) && (min == RUNM) && ((today != 1) && (today != 7))) // 5:00 on a weekday
              System.out.println ("Update Running " + hour24 + " " + min + " " + today); //runs some sort of update on the application
    }

    Something like this will work:
    long now = System.currentTimeMillis();
    GregorianCalendar cal = new GregorianCalendar();
    cal.set(Calendar.HOUR,17);
    cal.set(Calendar.MINUTE,0);
    cal.set(Calendar.SECOND,0);
    int day = cal.get(Calendar.DAYOFWEEK);
    int yearday = cal.get(Calendar.DAYOFYEAR);
    cal.set(Calendar.DAYOFYEAR,yearday + (day == Calendar.FRIDAY)? 3 : 1))
    long next = cal.getTime() //don't know... maybe needs another getTime()?
    Thread.currentThread.sleep(next-now);

  • I need help looping animation

    okay so i'm trying to loop the animation. i tryed using a for loop to loop it 4 times and it looped my trace statemnt 4 times but not my animation. any suggestions on how to loop the animation?
    below is the code i have tried
    import fl.motion.Animator;
    for (var i:Number = 0; i < 5; i++)
    trace(i);
    var this_xml:XML = <Motion duration="449" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">
    <source>
    <Source frameRate="19" x="0" y="0" scaleX="1" scaleY="1" rotation="0" elementType="movie clip" symbolName="cowanimation">
    <dimensions>
    <geom:Rectangle left="-8.5" top="-21.9" width="17.05" height="43.85"/>
    </dimensions>
    <transformationPoint>
    <geom:Point x="0.49853372434017595" y="0.4994298745724059"/>
    </transformationPoint>
    </Source>
    </source>
    <Keyframe index="0" tweenSnap="true">
    <tweens>
    <CustomEase>
    <geom:Point x="0.2096" y="0"/>
    <geom:Point x="0.811" y="1"/>
    </CustomEase>
    </tweens>
    </Keyframe>
    <Keyframe index="194" tweenSnap="true" x="67.65" y="-80.3" rotation="60">
    <tweens>
    <CustomEase>
    <geom:Point x="0.2096" y="0"/>
    <geom:Point x="0.811" y="1"/>
    </CustomEase>
    </tweens>
    </Keyframe>
    <Keyframe index="240" tweenSnap="true" x="77.75" y="-62.25" rotation="-150">
    <tweens>
    <CustomEase>
    <geom:Point x="0.2096" y="0"/>
    <geom:Point x="0.811" y="1"/>
    </CustomEase>
    </tweens>
    </Keyframe>
    <Keyframe index="378" tweenSnap="true" x="17.35" y="13.05">
    <tweens>
    <CustomEase>
    <geom:Point x="0.2096" y="0"/>
    <geom:Point x="0.811" y="1"/>
    </CustomEase>
    </tweens>
    </Keyframe>
    <Keyframe index="448" tweenSnap="true" x="0" y="0" rotation="0">
    <tweens>
    <CustomEase>
    <geom:Point x="0.2096" y="0"/>
    <geom:Point x="0.811" y="1"/>
    </CustomEase>
    </tweens>
    </Keyframe>
    </Motion>;
    var this_animator:Animator = new Animator(this_xml,this);
    this_animator.play()

    The problem with a for and while loop is that it will take complete the entire loop during the frame.  That is why u dint see it.  What u could do is increase the index by 1 each frame and then display that movie clip frame.  Via gotoAndStop(index).

  • How can I set up a program to stop at a certain time, or after a period of time?

    I am using LabVIEW to measure dc voltages over a period of time. The data is exported into an Excel file.  I would like to be able to set up the program to stop at a certain time, or after a certain number of hours.  This way when I run a test that will start near the end of the week and would stop on say, Saturday, it will not continue to record all the data after that, which I do not need. I would love to be able to set a time for it to end, but I  also wouldn't mind having it end, or stop recording data, after a certain voltage has been reached.

    Its hard to say without knowing more about how your program is set up.  Assuming the data aquisition is in a while loop, you can just wire a bunch of different stop conditions into a compound math node.  Then right click on it and select "OR".  A caveat about the comparisons I used in my little example: Comparing DBLs can lead to unexpected results when the two values are very close together.
    Message Edited by jasonhill on 06-16-2006 10:59 AM
    Attachments:
    stop the loop.PNG ‏5 KB

  • Need some help in making a label disappear for certain time

    hi
    i need to make a program for my java class
    this is the question
    Design and implement a memory game. In this game you show the user a sequence of
    random integer numbers in the range of 0 to 99, and then ask him to type these
    numbers. Display how many he has remembered as a score. The level of game depends
    on how many numbers are there in the sequence. The duration of the display for the
    sequence is the speed. The user can adjust the level and the speed.
    my question is how to view the numbers for the game and make them disappear after certain time
    in need help with the syntax for it
    this is what i made so far
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import java.awt.BorderLayout;
    import java.awt.GridLayout;
    import java.awt.FlowLayout;
    import java.awt.Color;
    import javax.swing.JButton;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    import java.awt.*;
    class game extends JFrame implements ActionListener {
    public static final int WIDTH = 500;
    public static final int HEIGHT = 300;
    public static final int x = 3;
    public static final int y = 3000;
    public static void main(String[] args) {
    game gui = new game( );
    gui.setVisible(true);
    public game( )
    super("MEMORY GAME");
    setSize(WIDTH, HEIGHT);
    setDefaultCloseOperation(JFrame.EXIT_ON_…
    setLayout(new BorderLayout( ));
    JPanel buttonPanel = new JPanel( );
    buttonPanel.setBackground(Color.LIGHT_GR…
    buttonPanel.setLayout(new FlowLayout( ));
    JButton b1 = new JButton("MAKE IT HAREDER!!!");
    b1.addActionListener(this);
    buttonPanel.add(b1);
    JButton b2 = new JButton("MAKE IT FASTER!!!");
    b2.addActionListener(this);
    buttonPanel.add(b2);
    add(buttonPanel, BorderLayout.SOUTH);
    public void actionPerformed(ActionEvent e)
    String buttonString = e.getActionCommand( );
    if (buttonString.equals("MAKE IT HAREDER!!!"))
    else if (buttonString.equals("MAKE IT FASTER!!!"))
    }

    To post code, use the code tags -- [code]Your Code[/code] will display asYour CodeOr use the code button above the editing area and paste your code between the {code}{code} tags it generates.
    I strongly suggest you forget about the GUI part and first make a console application that fulfils the game specifications. If you have problems with this, you can post your questions in the New to Java section of these forums.
    db

  • Web Service in JDK 6 - client resends request after certain time ?

    Hi,
    I am using the JAX-WS in JDK 6 to build a web service.
    The client sends a request to the server and server starts processing the request. The Server side processing is time consuming.
    I am not sure what exactly happens, but after a certain time, a new thread gets started for server-side processing. I have not used any multi-threading in my coding .
    Does JDK WS include a built-in timeout after which the client automatically resends the request to the server ?
    Thank you.

    Hi Andy,
    I found a workaround: I added some additional resources using a link "http://localhost:8079/"NAME"/:x/:x/:x/:x/:x/:x/:x​/:x/:x/:x/:x/:x/:x/:x/:x/:x" for each type (PUT, GET, POST, DELETE) where I handle the error message with the "Set HTTP Response Code VI"
    Attachments:
    ws_error.PNG ‏9 KB

  • IDVD is closing after a certain time.

    Hi, i made a movie with a sony Z1-HDV camera and made the montage in FCP. Than i export it with Quicktime 7.5. Than dropped it in iDVD. After a certain time iDVD just quits. With the below report.
    Also when i just open iDVD and open an other iDVD project and do nothing iDVD just quits after a certain time. Read below report.
    What to do???? I have to finish this project by wednesday!!!! HELP!!!
    Process: iDVD [512]
    Path: /Applications/iDVD.app/Contents/MacOS/iDVD
    Identifier: com.apple.iDVD
    Version: 7.0.2 (1100)
    Build Info: iDVD-11000000~17
    Code Type: X86 (Native)
    Parent Process: launchd [84]
    Date/Time: 2008-08-03 19:43:10.272 +0300
    OS Version: Mac OS X 10.5.4 (9E17)
    Report Version: 6
    Exception Type: EXCBADACCESS (SIGBUS)
    Exception Codes: KERNPROTECTIONFAILURE at 0x0000000000000000
    Crashed Thread: 22

    Yikes! You're on the very edge of a kernel panic if you haven't yet seen one. Something is amiss ....
    Are you using any external FW or USB HD's / 3rd party devices while attempting to burn an iDvd?
    If so, Restart your Mac without any 3rd party devices attached and try again. But first run apple's disc utilities to Repair Permissions. Assuming you have no less than 20GB's of available HD space on the boot volume and that all assets for iDvd are located on this same volume (your main HD and not on the external volume/s).
    Post back with your results.
    Message was edited by: SDMacuser

  • Does this code have a timer?

    I want an animation to run the same on all computers (I got it off the net). Is there a timer in it so that it will run the same speed on most computers? (this is not all the code - just the main parts)
    public class Bla extends Applet implements Runnable
        Thread runner;
        private Image Buffer;
        private Graphics gBuffer;
        public void init()
            Buffer=createImage(size().width,size().height);
            gBuffer=Buffer.getGraphics();
        public void start()
            if (runner == null)
                runner = new Thread (this);
                runner.start();
        public void stop()
            if (runner != null)
                runner.stop();
                runner = null;
        public void run()
            while(true)
                 /* Is this what the timer looks like? */
                //Thread sleeps for 15 milliseconds here
                try {runner.sleep(15);}
                catch (Exception e) { }
               /* Animation code goes here */
    }

    Oh no, you should be fine. I meant like generating dynamic fractal zooming or complex color shifts. The calculation overhead would start to overwhelm the sleep period on slower computers.

  • Looping animation not working with Timeline Action...

    I've used the Timline Actions Panel a few other times to loop animations by just selecting 'Complete' and then using sym.play(0); to return to the beginning - pretty hard to mess up I thought.  I have a new animation where this is just not working at all.  Could there be any other reason this is not working or perhaps something I'm just not looking at? 

    Hey,
    Sure, no problem.  Here's a link a a demo of it: http://www.damon9.com/dev/publish/web/EndofDays.html
    Not sure how much you can see from just that, but inside the Edge comp there's nothing crazy going on.  4 layers, 2 rotating 6 degrees a second, stops at 60 seconds (when it should start back from the beginning).  I've tried the usual Timeline Action sym.play(0); on complete and also just adding a trigger at 60 seconds of sym.play(0);
    Just can't imagine what else it could be.
    Thanks
    Damon

  • Running test at certain times in the day

    I am using LabVIEW 7.1 with Windows 2000.
    I have a program that needs to run for a set amount of days. Each day this program has certain duties to perform at certain times in the day. I have it able to run for a number of days but I am still working on the time intervals between cycles. I am looking for either a certain vi or a certain method on how to do this. I appreciate your help.
    Ron Deavers, CLD

    My inclination would be to use absolute timing instead of relative (elapsed) timing. The reason is twofold:
    1. Absolute timing is dead easy to code and seems easier to manage as you introduce new and arbitrary events that might fall between preexisting events that you've created. Assuming you're not looking for ms accuracy, polling overhead won't be a big deal.
    2. With elapsed time, you run the risk of progressively falling behind schedule if events take longer to execute than you have anticipated or coded for.
    This is one of those "I'm sure it's been coded many times before" applications, but it seemed like fun, so I coded it up using a standard state machine. Mine uses a schedule-info array to define events and assumes that the elements of the array are ordered chronologically.
    Hope it helps,
    John
    Attachments:
    Scheduler.zip ‏33 KB

  • Run VI at certain time

    Hello All,
    I want to know of there is a way to run a VI at a desired time. For example lets say I want a VI to automatically start running at 6 PM w/o me physically having to press the run button. Is there a way to tie a VI to the PC time clock and have it run at a desired time?
    Thanks

    As far as I know, Windows task scheduler can only run programs. You would have to create an exe from your project to make this work. If you could somehow schedule your VI to open at a certain time, you could just set it to run when opened.
    My suggestion: use code to wait in the VI itself. Then you can start the VI and push a button to have it wait until a certain time before actually starting.

Maybe you are looking for