Timer event doesn't listen to my if else statements how do stop it?

So I'm building a random generator of just a vector that i imported into flash and everything works just fine, almost. I added a timer to the creation of the vector. I also have some if else statements that are going to govern User Input. I realized that if the UI was initially outside of the parameters i've set it runs fine but once the once the function with the timer starts it never stops regardless of whether or not the UI is in the parameters I set. How do I stop the function when the UI is not what i want it to be?
Heres my code:
//initial universal variable declaration
var kface:Kobbyface;
var UI:Number;
var kfacex:Number;
var kfacey:Number;
var UIold:Number = 0;
var timer:Timer = new Timer(200);
//background rectangle
graphics.beginFill(0xFFFF00, 1);
graphics.drawRect(0,65, stage.stageWidth, stage.stageHeight);
graphics.endFill();
trace (inputnumber);
//eventlistener for click
gobutton.addEventListener(MouseEvent.CLICK, create);
function create(me:MouseEvent):void {
UI = Number(inputnumber.text);
if (isNaN(UI)) {
errormessages.text = "Kobby only responds to numbers"
else if (UI > 500) {
errormessages.text = "You're not ready for that many Kobbys"
else if (UI < 15) {
errormessages.text = "Come on you can handle more than that"
else{
createfaces();
//for loop///
function createfaces ():void {
////////timer for face animation///////
timer.addEventListener(TimerEvent.TIMER, animate);
timer.start();
function animate(evt:TimerEvent):void {
/////keep track of old number/////
if (UIold != 0) {
for (var i: int = 1; i<UIold + 1; i++) {
stage.removeChildAt(1);
    /////assign old number to new number////
UIold = UI;
for ( var i:int = 1; i<UI + 1; i++ ) {
trace( i );
////assign values to coordinate varialbes/////
var kfacex:Number = Math.random() * stage.stageWidth;
var kfacey:Number = Math.random() * stage.stageHeight + 65;
//creation of faces///
kface = new Kobbyface();
stage.addChild(kface);
kface.x = kfacex;
kface.y = kfacey;

you can apply the stop() method to your timer:
timer.stop();

Similar Messages

  • My Mail app opens unprompted everytime i reboot or awake my macbook pro from sleep.  This was not an issue until i shut down my laptop for the first time in a while 2 days ago.  ANy ideas how to stop this?

    I recently shut down my MacBook Pro for the first time in a long time.  SInce then, everytime i reboot or awake my laptop from sleep, the Mail app opens unprompted causing my computer to slow down incredibly, and some apps to freeze.  I have no idea how to stop this or why it even started doing this.  Any ideas on how to get it to stop? Thanks!

    I have this problem too with my Macbook Air. Mail opens automatically every time my laptop sleeps. I actually just asked about this in my own thread. However, it is not causing my apps to freeze.

  • JButton event listening if timer event already exists

    I would like to detect an event on a button, which is easy enough. But I already have a timer event happening and when I click a button nothing happens.
    I would like to store what button was pressed so that within the timer event I can check if a button and which button has been clicked and act on this.
    Code I have is below, taken out most of what isn't needed to explain what I have.
    int DELAY = 75;
    private Timer movingTimer;
    public BackgroundLayered(int inWidth, int inHeight)
              //loading images
              animation = new totalAnimation();
              animation.............................
              //displaying the images
              ImageIcon image = new ImageIcon("background2.jpg");
              JLabel background =.............................
              JPanel panel = new JPanel();
              //setting up labels
              cow1Image = animation.cow1Right();
              cow1 = new JLabel(cow1Image);
              cow1.setBounds(cow1startX, cow1startY, 20, 20);
              //adding buttons
              block = new JButton("Block");
              eat = new JButton("Eat");
                    //setting bounds
              block.setBounds(3, 305,70,30);
              eat.setBounds(76, 305,70,30);
              //start timer
              movingTimer = new Timer(DELAY,new TimerHandler());
              movingTimer.start();
              //adding components to display
                   // Labels added to Palette layer and buttons to default layer
              getLayeredPane().add(cow0, JLayeredPane.PALETTE_LAYER);
              getLayeredPane().add(cow1, JLayeredPane.PALETTE_LAYER);
              getLayeredPane().add(block, JLayeredPane.DEFAULT_LAYER);
              panel.setOpaque(false);
              setContentPane(panel);
           //this event handler doesnt get invoked when buttons are pressed
            public void actionPerformed(ActionEvent event)
                                System.out.println("button pressed");
    private class TimerHandler implements ActionListener
              public void actionPerformed(ActionEvent actionEvent)
                   //moving the cows
                   cow0.setLocation(cow0startX, cow0startY);
                   cow1.setLocation(cow1startX, cow1startY);
                   //check for collisions
                   collisionCow0 = obstacle.checkCol1Cow0();
                   collisionCow1 = obstacle.checkCol1Cow1();
                   cowBack = obstacle.cowob1Collided();
              }

    Please ignore this topic! I have now resolved the problem.
    Having only done event handling in applets, I didnt realise you had to add the actionlistener to each button when doing it on desktop also!

  • Looping through inbox items on timer event is really slow...?

    Hi,
    I have an issue with a email sync event that I am running.  Essentially, I am given a date (the received date of the last email synced) via another process and then need to return all the emails in the user's inbox the where receivedDate > this given
    date.
    I have a timer object than triggers my sync event every 15 mins.  I also have a button that allows the user to manually activate the sync - this basically changes the timer to 3 secs and so it fires the sync event.
    If the sync event is fired manually as per above, it loops through everything quite quickly (~12,000 emails in 30 secs) and I can stored the sender/recipient and received time data I require from these in a list of objects, which I sync later on in a background
    process.  During this loop the main UI freezes up, which is fine since I show a progress bar so the user knows how long they need to wait, and a large sync like this should only occur on their first sync theoretically.  If the first sync event is
    fired without the manual input - so still called from the same timer event, but just on the normal 15 min event, not the shortened 3 sec one - then it runs differently.  The sync takes a lot lot longer, and the UI doesn't freeze up.
    I presume this might be because it is fired slightly differently and does not hog up the main thread, but rather shares it with normal Outlook operations.  Maybe the operations are being run on a background thread and then keep having to jump into the
    main thread to access the email items...?  Either way, I'm not quite sure how this is happening since the only difference is the user pressing a button that changes the timer.interval.  The code that is run is the same, and the button press doesn't
    trigger the actual sync itself.
    Is there a way I can force this first sync to always run solely in the main thread, it can freeze up Outlook and show the progress bar until it is done?  Ideally any subsequent syncs would then be run with no progress bar and no freezing up of the UI.
    Many thanks,
    Tom

    Hello Tom,
    > Maybe the operations are being run on a background thread and then keep having to jump into the main thread to access the email items...?
    You shouldn't use another threads when dealing with the Outlook object model. Office applications use the single threaded apartment (STA) model and don't support multithreading. All calls made from another threads are marshalled by Outlook to the main
    thread. However, you can use a low-level code (Extended MAPI) to access the data from secondary threads. For example, you can use Redemption which is based on Extended MAPI.
    >  it loops through everything quite quickly (~12,000 emails in 30 secs)
    Instead of looping over all items in the folder I'd recommend using the
    Find/FindNext
    or
    Restrict methods of the Items class. You can read more about them in the following articles:
    How To: Use Find and FindNext methods to retrieve Outlook mail items from a folder (C#, VB.NET)
    How To: Use Restrict method to retrieve Outlook mail items from a folder
    You can use the System.Windows.Forms.Timer class which uses the main thread for invoking the Tick event. The .NET
    Framework Class Library provides three different timer classes: System.Windows.Forms.Timer, System.Timers.Timer, and System.Threading.Timer. Each of these classes has been designed and optimized for use in different situations. The Comparing
    the Timer Classes in the .NET Framework Class Library article examines the three timer classes and helps you gain an understanding of how and when each class should be used.
    Also you may find the
    AdvancedSearch method of the Application class helpful. Pay special attention to the fact that the search is performed in another thread. You don’t need to run another thread manually since the
    AdvancedSearch method runs it automatically in the background. See
    Advanced search in Outlook programmatically: C#, VB.NET for more information.

  • Time Machine doesn't make backups

    Hi,
    I have problems with Time Machine. I deleted by error the backup file in Time Capsule, but now Time Machine doesn't create a new one, simply it doesn't work. External disks are recognized (Time Capsule or USB disk) but it doesn't make backups, only appears the "preparing" for one or two seconds and then nothing. It's the same if I try to make backups on a external USB disk.
    I can not enter to Time Machine to see the backups.
    Looking at "Console" for the last logs there many crash reported, for example:
    18/02/09 11:59:26 /System/Library/CoreServices/backupd[3053] Backup requested by user
    18/02/09 11:59:26 /System/Library/CoreServices/backupd[3053] Starting standard backup
    18/02/09 11:59:27 ReportCrash[3054] Formulating crash report for process backupd[3053]
    18/02/09 11:59:28 com.apple.launchd[1] (com.apple.backupd[3053]) Exited abnormally: Trace/BPT trap
    18/02/09 11:59:28 ReportCrash[3054] Saved crashreport to /Library/Logs/CrashReporter/backupd2009-02-18-115926GK.crash using uid: 0 gid: 0, euid: 0 egid: 0
    Any one with a similar problem???
    Is it possible to reset Time Machine in order to restart the backups?
    I bought Time Capsule and I can't use Time Machine!!!!
    Thanks.

    magali mistral wrote:
    Hello!
    Thanks for your message. The Time Machine Buddy widget was helpful. Although I couldn't mark the text, copy and insert it here.
    You should be able to highlight them by dragging your mouse over them, then cmd-C to copy to the clipboard, then cmd-V to copy it here.
    Event store UUID don't match for Volume: Macintosh HD
    This means TM isn't sure whether the last changes to your internal HD got logged to OSX's File System Event Store, a log of all changes that TM can normally use to see what needs to be backed-up. Most commonly caused by an abnormal shutdown.
    Node requires deep traversal:/
    Reason: kFSEDBE even FlagMustScanSubDrs /kFSEDBE vent Flag Reason Deep Backup/
    Since it can't trust the Event Store, this means it has to examine every file and folder on your HD. Quite a lengthy procedure, of course.
    Then it said - I didn't copy that - something like "thinning out" isn't necessary because there was still 368 GB or so space left - 7 GB were backed up - but it did "thin out" some outdated file afterall, whatever that is - hope it didn't delete something I wanted to keep.
    All normal. TM automatically deletes it's hourly backups after 24 hours, except the first of the day, which is called a Daily backup. That is kept for a month, when a similar process converts the first of a week into a Weekly backup, and deletes the others.
    Only when the disk is near full (TM does need some workspace) will you see deletion of one or more of the oldest weeklies, instead of the first message.
    Then the next problem started. It wasn't possible to eject the external drive. I waited for quite some time but each time tried to eject it, a window opened saying that it was still in use and could not be ejected. Although it had defenitely finished doing the backup and the next one was to be done about half an hour later.
    Is there anything else on your external drive, besides TM backups? Could you have been looking at it via the Finder, when you tried to eject it?
    Try this: de-select the drive (chose the "none" icon) in TM's preferences, then quit System Preferences. Then go back and re-select it. Sometimes this resets TM's lock on the drive.
    If not, and it happens again, try turning TM off, then ejecting the TM drive. You shouldn't have to do this -- TM is supposed to let you eject it, then automatically do another backup whenever you re-connect it.
    Now that you have a good full backup, just keep an eye on it. Your incremental backups should be very, very quick under normal circumstances.
    There are a few things that may cause long backups, such as an abnormal shutdown, certain hardware repairs, not letting TM back up for several days (seems to be about 10, some say), and the use of certain apps. File Vault, Entourage, vmWare, running Windoze are a few. If you do see long backups, post the messages here in a new thread.

  • Process instances stop at timer event

    Hi,
    I modelled a process with intermediate timer event. When this timer expires an automatic activity is invoked which checks certain conditions. If these conditions are not met the process token returns to the timer until the conditions are met and another process path is entered. I observed quite a lot of process instances which stoped at this timer event, meaning: the timer doesn't expire any more and the entire process instance stands still. The reason for this seems to be:
    - database filled up (ok, this shouldn't happen. I accept that this has severe consequences)
    - restart of application or netweaver
    - running process archiving run
    Is there a way to reactivate these process instances other than aborting the current instance and starting a new one?
    Timer events use GalaxyTimerJob. I assume an appropriate database entry failed. Can I add this missing table entry by executing SQL commands or isn't it as easy as that?
    Thanks
    Regards
    Anja

    Hi Nick,
    yes, suspending and resuming doesn't change anything. 'Instance restart': you mean restarting NetWeaver? In fact, it seems to me, that fixes the problem for some process instances, but too many stay in their "corrupt" status.
    Can I execute some SQL statements to add this GalaxyTimerJob database entry? Even if there are such statements, would it be too critical as the various process instances might be in different states and the execution of such statements might rather brake than fix things?
    Regards
    Anja

  • Timer event with parameter

    Hi guys,
    I implemented a BPM with 3 Times inputs and 3 timers. I need to set the TimeDate of the Timer Event with the three inputs. How can I do it? I tried with to create a DataObject with three Time attributes, before the Timer activities I assign the inputs to the data objects and in the Time Date I inserted the Expression with the data object attributes but it doesn't work!
    I tried also to insert three string as inputs (instead the Time) and then I insterted a trasformation before the Timer activities but it doesn't work too...
    Please help me!
    Thanks

    I solved inserting -'2h' in the Timer expression...So the question now is: Why the input DateTime has increased of 2 hours? I will open a topic...
    Thanks

  • Query WLI Timer Event Generator's status

    Hi guys,
    I am using WLI 10.3. Does anyone know how to query the status of Timer Event Generator programatically?
    I am able to create and start the timer programatically through JMX and WebLogicDeploymentManager but not getting the status
    of timer. It doesn't even look like this is possible through TimerEventGenRuntimeMBean or am I missing something?
    Thanks
    Sam

    Ok, you can basically leave the messageType as XML
    and for the Timer EG configuration, for the optional message you can add <dummy/> this will fire the request and start a workflow or whatever is bound to the channel.

  • Time Machine doesn't notice new files.

    Alright, so I have Time Machine set up with my external drive. Everything with the setup process went smoothly, and the initial backup successfully copied everything. Since then, however, Time Machine doesn't notice when new files appear. If I create a new project in Logic, for example, it will never get backed up.
    Here's what I know:
    -The only thing I have told Time Machine to not back up is the other partition on my external drive.
    -Logic project files get stored to the default ~/Music/Logic/ directory, which is on my internal hard drive.
    -Time Machine will never notice that new projects have been added, no matter how long I wait (hours, days, weeks) or if I tell Time Machine to back up now.
    -Time Machine will back up the files if I format its partition and start fresh with the same configuration.
    -Reviewing the Backup.log files shows that Time Machine isn't detecting any significant changes (or new files, in my case).
    -Other directories are working fine, such as /Library/WebServer/Documents/
    Anybody have any ideas?

    According to Ars' Leopard review, Time Machine uses a new file system change notification system framework called FSEvents (which is explained quite well in the Ars article). Since FSEvents depends on the system used by Spotlight, can you tell us whether Spotlight is updating or not?
    If Spotlight is up to date, the next thing to see is whether the FSEvents framework is capable of receiving updates. To do so, the fseventsd process must be running (I imagine that you should be able to see if under Activity Monitor). If it is not running, there lies the problem: you must launch it and make sure that is launches at startup.
    If the fsevetsd is running and you have free disk space (the FSEvents framework stores files events on a directory .fseventsd at the root of each file system), you might want to check that the .fseventsd directory of the file system where you have your home direcotry does not have a no_log file inside telling it not to log events for that file system. If such a file does exist, deleting it should do the trick (no guarantees though, I don't have Tiger yet to test my words!). If it doesn't exist, I hope someone else can help you further along, because I am afraid that I have run out of suggestions.
    Good luck.

  • Capture phase never happens for timer event

    I am trying to comprehend event flow, event bubbling,
    listeners, etc. I created a test class called TimerExample to
    generate some events. It kinda works, but the eventListeners
    listening for the event during the capture phase are never
    triggered. Does this mean timer events don't bubble? Is there some
    good rule of thumb for which events bubble and which do not? If
    there's no rule of thumb, is there some list or reference in the
    on-line flash docs?

    Looking at Adobe's fl.controls.BaseButton class shows the
    pattern you need. Find the file by searching for a file called
    "BaseButton.as" on your computer, and if you find more than one,
    it's the one inside the "controls" folder inside the "fl" folder.
    It shows a good pattern to use when you want a Timer event to
    bubble. In the BaseButton class, repeating BUTTON_DOWN events are
    broadcast when anything that extends BaseButton is pressed and held
    by the user.
    Basic flow:
    1. The class listens for all MouseEvent events with the same
    handler: mouseEventHandler()
    2. If mouseEventHandler(event:MouseEvent) gets an event of
    type MouseEvent.MOUSE_DOWN, it calls startPress.
    3. The startPress() method starts the pressTimer instance of
    Timer
    4. The Timer is calling buttonDown() every millisecond.
    (really?)
    5. The buttonDown() method dispatches the BUTTON_DOWN
    component event with bubbling set to true.
    Hope this helps.
    -Mike

  • How to stop Timer event inside movie clip that does not exist?

    Hello. I am using Adobe Flash CS6.
    As this topic title says. how to stop Timer event nside movieclip that does not exist?
    I mean my fla stracture is  there are 2 frames on main timeline, and I put mcA on frame 2.
    And I put a button on root that does
    if(currentFrame ==1)
    gotoAndStop(2);
    else if (currentFrame ==2)
    gotoAndStop(1);
    And mcA has AS inside and it is
    var T_Timer:Timer = new Timer(1000,0)
    T_Timer.addEventListener(TimerEvent.TIMER, test)
    function test(e:TimerEvent):void{
    trace("Timer active")
    T_Timer.start();
    I need to stop T_TImer from root on frame 1, not on frame 2.
    but, "mcA.T_Timer.stop();" won't work.
    I get TypeError: Error #1010 error.
    I don't know how to stop this timer event. I have to stop it from root, and I can't use EVENT_REMOVED in this case.

    If the object doesn't exist you cannot do anything relative to targeting it.  Maybe you should move the timer to the main timeline where you can access it any time.

  • Java SystemTray with timer event

    I have just recently began working with the java system tray feature. In my application I have took the example from http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/systemtray/ for an example as to how this works.
    My application also has a timer event that goes off every two seconds and checks for new messages. However if I open up the system tray popup menu, then the rest of the application hangs and waits for the pop up window to close. Is there any way to make the system tray so that the rest of the application does not freeze waiting for the menu to go away or a choice to be selected? I wold like the timer event to go off every 2 seconds, even if I have the system tray popup menu open.
    Thanks for any help or suggestions.

    Hmm. It's not that the Timer is stopped, it's that the TrayIcon displays the popup on the EDT and blocks actionPerformed -- which also has to run on the EDT -- till the popup is closed. Swing Timer by default coalesces multiple timer events when there's a backlog.
    As the showing of the popup is handled by the native peer, it doesn't look like there'll be any solution with a Swing Timer. Your problem should be solvable with java.util.Timer and TimerTask.
    Try this code, then uncomment the setCoalesce(false) and try it again. Note the difference.import java.awt.AWTException;
    import java.awt.Color;
    import java.awt.Graphics2D;
    import java.awt.Image;
    import java.awt.MenuItem;
    import java.awt.PopupMenu;
    import java.awt.SystemTray;
    import java.awt.TrayIcon;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.image.BufferedImage;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    public class TrayIconTest {
       public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
             @Override
             public void run() {
                new TrayIconTest().makeUI();
       public void makeUI() {
          PopupMenu popup = new PopupMenu();
          popup.add(new MenuItem("One"));
          popup.add(new MenuItem("Two"));
          TrayIcon trayIcon = new TrayIcon(getImage(), null, popup);
          try {
             SystemTray.getSystemTray().add(trayIcon);
          } catch (AWTException ex) {
             ex.printStackTrace();
          JFrame frame = new JFrame();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setSize(200, 200);
          frame.setLocationRelativeTo(null);
          frame.setVisible(true);
          javax.swing.Timer swingTimer = new javax.swing.Timer(1000, new ActionListener() {
             int count = 0;
             @Override
             public void actionPerformed(ActionEvent e) {
                System.out.println("Swing Count: " + count++);
          //swingTimer.setCoalesce(false);
          swingTimer.start();
          java.util.TimerTask timerTask = new java.util.TimerTask() {
             int count = 0;
             @Override
             public void run() {
                System.out.println("Util Count: " + count++);
          java.util.Timer utilTimer = new java.util.Timer();
          utilTimer.scheduleAtFixedRate(timerTask, 1200, 1000);
       private Image getImage() {
          BufferedImage image = new BufferedImage(16, 16,
                BufferedImage.TYPE_INT_ARGB);
          Graphics2D g2 = image.createGraphics();
          g2.setColor(Color.RED);
          g2.fillOval(1, 1, 14, 14);
          g2.setColor(Color.YELLOW);
          g2.fillOval(5, 5, 6, 6);
          return image;
    }db

  • Logical time in deleted time events - RPUAUD00

    Dear All,
    We are using standard report RPUAUD00 to read deleted time events (Infotype 2011) from system. In certain cases, deletion entries are displayed without any entry for field LTIME (Logical Time). Can any one throw some light, as of why and how this LTIME entry is not logged in change log?
    Thank you.
    Regards,
    Kartik

    Dear All,
    We tried replicating this behaviour, but unable to. Any thoughts on this behaviour please..
    Regards,
    Kartik

  • To transfer time events from external time recording system to sap r/3

    hi all,
          I have a task to make an interface program between external time recording and sap r/3, and then to transfer the time events from that external system to sap system with the help of an rfc, i have got some information like the data first has to be transferred to the table CC1TEV and then from this table the data will be uploaded to 2011 infotype with the help of a standard program, but i am unable to find a solution for making the interface program and the RFC or BAPI which will transfer the records from external system.
        if anybody has any information on this plz help me out to solve this problem.

    Which recorgding terminals using to capture time events? They should have give some guidelines about this?
    Regards
    niranjan

  • After upgrading to iOS 5, my iPhone 4 takes a very long time to open digitally signed emails. I've tried with the SMIME settings enabled, but that doesn't help either. Any ideas on how to resolve this?  Thanks in advance.

    After upgrading to iOS 5, my iPhone 4 takes a very long time to open digitally signed emails. I've tried with the SMIME settings enabled, but that doesn't help either. Any ideas on how to resolve this?  Thanks in advance.

    I suspect you may have a corrupt photo or image that is causing the sync to fail or quit. You might want to try removing all of your photos by deselecting them in iTunes then sync - and try adding them by each sub-folders until you are able to nail down which sub-folder of photos, that causes the sync to stop or gives you errors.

Maybe you are looking for

  • Blotch on my 13 inch macbook pro screen non retina

    i have a black blotch on my 13 inch non retina macbook pro mid 2012. the warranty expires in august. Since I requested for this mac from my relatives, i dont have a reciept but the waranty shows on apple's site. i paid for the mac and i live in a cou

  • Get Field Values from Table using Java api

    I am using the example java code "RetrieveLimitedRecords" that can be found at : https://help.sap.com/javadocs/MDM71/current/API/index.html The code give the expected result and retrieves the record count for the main table Now I want to get the valu

  • Regarding excised report

    respected sir,     plz sir give me crystal report of r.g.23a part2

  • Why can't I display on my projector?

    My projector that I just bought has VGA input, and A/V input cables. I was trying to figure out a way to go from my mini displayport to VGA. I had a mini displayport to HDMI converter on hand, so I bought an HDMI to VGA cord. When I put it all togeth

  • Solaris 10 8/07 on sparc jumpstart issue

    hi, I just tried to jumpstart via 'boot net:dhcp - install' the 8/07 release. No changes on my servers, only a link to the new repository. Though it throws me into the interactive install pretty early. I remeber from the earlier days that the 'questi