Any sleep/pause/wait function in flex/AS

I am new to flex and this forum. So can anyone tell me how to produce a delay in my program. I just need 3 second delay in my program.
I just need to write a delay function. The function look like..
private function delay():void
     // 3 second delay code
Thank you,
--Amit

If this post answered your question or helped, please mark it as such.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  creationComplete="init();">
  <mx:Script>
    <![CDATA[
      private var myTimer1:Timer;
      private var myTimer2:Timer;
      [Bindable] private var num1:uint = 0;
      [Bindable] private var num2:uint = 0;
      private function init():void{
        myTimer1 = new Timer(3000, 1);
        myTimer1.addEventListener(TimerEvent.TIMER_COMPLETE, timerHandler1);
        myTimer1.start();
        myTimer2 = new Timer(1000, 0);
        myTimer2.addEventListener(TimerEvent.TIMER, timerHandler2);
        myTimer2.start();
      public function timerHandler1(event:TimerEvent):void {
        num1++;
      public function timerHandler2(event:TimerEvent):void {
        num2++;
    ]]>
  </mx:Script>
  <mx:Label id="lbl_1" fontSize="40" text="{String(num1)}"/>
  <mx:Label id="lbl_2" fontSize="40" text="{String(num2)}"/>
</mx:Application>

Similar Messages

  • Sleep or Delay function

    Hi All
    Is there any Sleep or Delay function available in Indesign Javascript.
    I need that function to proceed my task.
    Sajeev

    Thanks Tomaxxi. It works
    Sajeev

  • Using Sleep Function in Flex

    Hi,
    I have something here which takes some time for the
    HTTPService to communicate with an external server that hosts the
    database. The only issue here is that when I would like to change
    the view state to see the information, the application cannot
    handle it on the DataGrid due to the time lapse.
    In programming languages, there is a function called sleep
    that I can stop the program till certain stage is committed. In
    Flex, I tried to use setInterval(1000) to commit 10 seconds to put
    the program to sleep, but most manuals require me to apply
    setInterval with a function or two. Could I just do
    setInterval(1000) for my program to sleep for 10 seconds instead of
    waiting for it to apply to another function in Flex?
    Thanks in advance.
    Alice

    Hi,
    As Dmitri mentioned, you should listen to the result event of
    the HTTPService. HTTPService calls to the server are asynchronous,
    so HTTPService will dispatch a result event when the response from
    the server is received.
    Please find more details on how to listen for result and
    fault events of the HTTPService at the URL below.
    http://livedocs.adobe.com/flex/3/html/data_access_2.html#193905
    You can also have a look at concept called Binding in Flex.
    This will allow you to bind your DataGrid to a ArrayCollection and
    when the ArrayCollection is modified, your DataGrid will reflect
    the changes. Please find more details on Binding at the URL below.
    http://livedocs.adobe.com/flex/3/html/databinding_1.html
    Hope this helps.

  • Why does that entire thread goes to sleep when we put a wait function in time critical loop?

    why does that entire thread goes to sleep when we put a wait function in time critical loop but not when it is not time critical

    Norbert B wrote:
    Ujjval,
    in a RT system, priorities have (in general) increased effect on the execution of the application.
    It is recommended that you only have a single task in your RT program at "time critical". If you have two task "time critical" (that means you are running into issues caused by your quoted "feature"), you have a flaw in your application architecture.
    Since LV 7.1, it is recommended to work with Timed Loops in order to prioritize tasks on a RT system. Timed Loops are executed on priorities between "time critical" and "above normal". Each Timed Loop will execute its content in a single thread in order to keep a good overview of the timing (like finished late [i-1]). Using those structures (and according settings) in a reasoned manner will prevent your RT system to run into priority issues.
    Ujjval Shah wrote:
    [...]also i would really appreciate if i can get more documentations regarding how LV creates threads and assigns subvis to them[...]
    You will have a real hard time to go into this very deep. This is the feature of LV: you can just use multithreading (multicores) without the needed knowledge of scheduling and load balancing. This makes LV programming in general very easy in comparison to e.g. ANSI C (in regard of multithreading). So creation of threads, distribution of tasks to the threads are abstracted and most often not visible to the programmer.
    There are some switches and levers you can "play around" in order to make LV to behave differently in this matter. But this most often requires  deep LV knowledge and cannot be explained in a simple posting.....
    hope this helps,
    Norbert 
    Amen to that!
    The question can not be fully answered without digging into the internals of the OS LV is run on because LV works with the OS and lets it do the scheduling.
    Yes that note applies to pre- LV 7 RT. When run under RT the ONE Time Critical loop was guarenteed to stay determinisitic.
    Since then the Timed Loop was introduced that allowed multiple levels of priority and later allowed us to assign which CPU the code would run on.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How to isolate the wait function to one part of the code

    I'm buildling an ecg montoring system along with programming an external stimulator using TTL pulses to work along side the information obtained from the ECG.The most important of  these features is the heart rate. However, whenever I activate my pulse trains in the code, the DAQmx Wait Until Done.vi function pauses everything in the code, including the part of my code that monitors the heart rate, which uses time to measure it. What I would like, is the wait function to only affect the pulse train generators without pausing anything else in the code. Is this possible? And if so how can I make it happen?
    I will attach my vi
    Solved!
    Go to Solution.
    Attachments:
    simulatejed.vi ‏130 KB

    Your problem is that everything is in the same loop.  So the longest operation is going to determine the loop rate (and therefore processing rate).  What you really need to do is separate your tasks into separate loops.  Use queues and/or notifiers to communicate your data and commands between loops.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Is there a way to set up a 'dial string' with a 'wait' function?

    I'm trying to set up calling my work voicemail. On the blackberry i could set up a dial string with a wait function. So when i dialed the voicemail #, once it answered I could hit a button on the phone and it would send the next set of characters (in this case, my extension #), then wait again, and once I got my password prompt, i could again send the next characters (now my password). I can find the way to put in a pause...but it isn't enough and doesn't do what i want it to do. How can i do this on my iPhone?
    It really is important in that i don't want to have to enter these characters while i'm driving.

    Thanks for the reply....i've tried that and it's not doing what i want it to. Our VM sometimes has delays, so its impossible to predict home many pauses i need....really need a wait function.
    Thanks

  • Usage of WAIT function in Oracle Workflow

    Hi all,
    I am new to Oracle Workflow, I interested to learn about WAIT function, So I gone through the docs provided by Oracle. But I am not able to figure it out. Can any one explain me abuot WAIT function in 2 or 3 lines.
    Regards
    Prakash

    check these -
    Wait Activity (Oracle Workflow Developer's Guide)
    Oracle Workflow Developer's Guide
    Workflow Wait Function

  • Under CentOS 6 x64, Java Thread.sleep()/Object.wait() will be influenced.

    Under CentOS 6 x64, Java Thread.sleep()/Object.wait() will be influenced while changing OS time.
    I found a BUG in java bug list. The bug id is 6311057 with fixed status. But I find it still existing.
    Under CentOS6 x64 platform, on JDK1.6.0_33, the bug still exists.
    But under CentOS5 x64 platform, on same JDK, the problem does not exist.
    Could anyone give me help? Thanks.
    The bug's link is http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6311057
    Edited by: user10222290 on 2012-6-13 下午9:22

    user10222290 wrote:
    One server could want to synchronize it's OS time with another server when they connected each other for some business reasons. I have 3 computers running pretty much continuously with time synchronised from one of the internet time servers. They never seem to be more than about 1/10 th second apart and any time corrections are very very small.
    Some threads have started to run before changing OS time, so these thread's sleep process will be influenced sometime seriously.I understand that but I would only expect this to be a problem when there is a significant change to the OS time. If each server is synchronized to a time server then the time corrections will be very very small.
    If OS time was turned back some days, these thread could not wake up untill some days passed.Agreed but why would the "OS time be turned back some days" ?
    This whole problem seems to me to arise because the servers are not time synchronized. Now I understand that there may be concerns about the security of external time servers but it is easy enough to make one of the local servers a master and act as a time server to the others.
    I have a small server that typically services some 30 or so external clients. I don't have any control over the clients and do not know anything about the setting of their system clocks. The clients send a time signal as part of a heartbeat and from this the server keeps track of the local time on each client and compensates for any difference when writing logs. I have seen this difference as big as 4 months but the compensation corrects it to within about a second. No adjustment of clocks is required for this.
    I still don't see this 'bug' as a serious bug. I just see a design problem to be solved without changing the OS time on any computer. I know this can be done since I do it. The only problem I see is if you want an accuracy of better than about 20 mS but that does not seem to be required for your system.
    Note - if Oracle accept your new bug report it could take years to fix even if lots of people vote for it to be fixed.

  • Help with a simple pause-code function

    For a week I've been trying to figure out a simple pause-code
    function fror AS 3.0. I need something that pauses AS code for set
    amounts of time. People have tried to help me on this forum, but
    I've still not been able to make the code work.
    Here is what I have at the moment for pause-code (not
    working):
    var intID;
    intID = setInterval(delay, 3000); //this tells flash to wait
    3 seconds
    function delay(){
    clearInterval(intID);
    _root.gotoAndPlay(1); // or do something else...
    The person who supplied me with this code did not include the
    first line "var intID", but as a new flash user, I wasn't sure how
    else to declare intID. Could someone with some flash experience
    walk me through the steps of creating a pause-code function or add
    to the one I have already provided. When I use the above code in my
    flash document, the pause feature does not work at all. It
    essentially skips over the setInterval and clearInterval functions
    and plays the root clip in delay(). I need code meant for AS 3.0
    and I'm becoming increasingly desperate for a response.
    I hope this is understandable and thank you for taking a
    look,
    Sam

    Hello KGlad,
    Thankyou for that information. I had no idea lol. Could you
    please clarify and explain a little more about using the timer
    class to delay execution of code? Possibly provide an example? I
    would be very grateful.
    Thanks,
    Sam

  • How i get by with the sleep, pause issue after 1.0.2 update

    ok. i'm sure you guys are aware of the ipod sleeping/pausing issue after updating your ipod to 1.0.2. my ipod will pause whenever it is in the jensen dock station and the green battery indicator shows up. whenever i use the dock or remote to unpause the song, a few seconds later, it pauses again. so instead of using the dock or remote to play, unpause, whatever, i connect the ipod to the dock and use the wheel to navigate and 'only' use the play/pause button on the ipod itself to kick off the playing of music. if i go back to the remote, the ipod pauses. if i only use the menu and play/pause button on the wheel, my songs do not pause. it sure was nice using the remote before 1.0.2. i mean, it did come with the dock for my remoting pleasure but alas, i shall wait on the next update. hope this helps someone.

    I will have to try that... I took my iPod to work today and plugged it into my JBL docking station and it was skipping. I did notice it seemed to go to sleep more often when I used the remote... There's a whole other forum on this maybe you could check out too. But it's really annoying and I hope Apple comes out with a fix soon! I will definitely try to use the iPod wheel tomorrow and not the remote.

  • My ipod nano 6th generation does not start on pressing the sleep/pause button  or pressing both sound low and sleep pause button.it starts while connected to power it is fully charges

    i have an ipod nano 6th generation .version 1.2 yesterday i  restored it on i tunes  using my system window 7. for the last few days it does not start when the sleep/pause button is pressed.or even by pressing the both button sleep/pause and sound minus..It starts while connected to power. and then continues working. I can not put off it and it automatically goes off after some time its performance is ok  after starting by connecting to power and then disconnecting the cord.
    what would be the reason and what to do?>

    Call Apple Care as you are still under warranty.  

  • "Wait Function" swf works in Mac, Not in Windows

    Hi,
    I have got a Flash movie [swf file] that plays the intro
    part("Scene 1", 1) to ("Scene 1", 55), and then go to
    ("Scene 2", 1) smoothly in Mac environment. When I run the
    same swf movie in windows, it plays the intro part only and then
    stops. It does not go to Scene 2 at all.
    I am making use of a wait function in the actions.
    I changed 'frame number' ("Scene 2", 1) to 'label' ("Scene
    2", "start") and tested it again, but it still does not work in
    windows environment but runs smoothly in Mac.
    Kindly advise what is the problem exactly.

    It turns out I was wrong: this function did work. However, when I then saved the file as an SVG, Illustrator ignored the document proportions. To correct this, I had to set the export option preserveEditability = true (of all things ...). Apparently it's a feature of Illustrator CC to not include the document proportions in SVG files by default.

  • Issue in Wait function in APEXP workflow

    Hi Friends,
    I am working on APEXP R12 12.1.3 version
    Requirement: user expecting the email notification 48hr after summation of expense if he is not submitted the image.
    Customization I have done: I have used the standard Wait function after “wait for image receipt” node to wait the workflow for 48 and sending the notification. i am passing node attribute value as Relative Time :0.5
    Issue: Wait is not working user is getting the email notification immediately

    Appreciated  for the  response and thanks in advance

  • Any alternative to ago function

    Hello,
    I am using obiee 11g.Trying to use ago function at quarter level with the date prompts as filter
    instead of year prompt but somehow the data is not matching properly.
    Would like to know if there is any alternative to ago function?
    I just want to calcultate the count(distinct(id)) for current and previous quarter,where the report gets filtered by date fields.
    The report has user column,quarter column and the currrentcount and previous count.
    like
    user1->Q1->10->19
    user1->Q2->20->10
    User3->Q1->11->26
    Any help on this please?
    Thanks

    Hello,
    Thanks for reply.
    Is the grain below quarter level?
    ------> Calc date is below quarter level in the time dimension,Time dimesnion has FS Year(level1)->FS Quarter(level2)->Cal Date and Time key(Time key is the primary key with the combination of cal date and the pk of some other table (level3))
    Does quarter exists as a field in your date dimension?
    --------->Yes Fs Quarter is a field/column in the table and in the dimension
    check if quarter is a chronological key, does your quarter contain year in it(2011-02)?
    -------->In each level i have key defined, also in the FS Quarter i have.
    In the level3 i have both the key defined as key but cal_date as pk.
    Yes, Data of the qtarter is in the form 2012-01.
    Do you have quarter in your report, without date field?
    --------->yes, the report has FS_qtr,count for current qtr,count for previous qtr using ago function
    and the filter used is cal_date>='01-JUN-11'
    facts->
    There is a view in the database which is being created for time dimesnion.
    The view has
    FS_Year , FS_Qtr , Calc_Date ,Cal_month , cal_qtr, TimeKey(PK) , Pk_from someother_table_acting_as_fk.
    Please let me know where i am going wrong?
    One more thing i would like to add if i use the filter as FS_YEAR>=2011 then the counts comes perfectly.Problem is with cal date field.Just not bale to understnd where i am i going wrong?
    Please help
    Thanks
    Edited by: user123 on Feb 10, 2012 11:00 AM

  • Using the Wait function in while loops?

    Hi,
    I have a rather complicated top level VI with about 20 subVIs and the main VI has on big while loop around it and another smaller one inside, basically it runs rather slow and I have no idea how to set the wait function. I mean what factors should I consider..what would be the difference between setting it to 10 and 100 (besides the obvious 10ms vs 100ms)? I just want to increase the performance of the executable, so it is not that slow. Can you offer some hints as to what I need to take into consideration when determining my delay? And also, are while loops the only place that I should use the delay or are there other instances too?

    Adding waits is not a fix-all for slow running applications. Its just one thing that can be done to improve things. If you determine that a sub-vi is causing your problems then you need to find out exactly what that vi is doing to slow you down. If its because there is a loop inside it that is running constantly as fast as it can, then a delay in that loop may help. If that is not your problem then you need to look at other ways to boost performance. It sounds like you have alot of locals variables, each instance of a local variable makes a copy of the data that's in the control. If the controls/indicators that you have local variables of contain large amounts of data then you may be filling up memor
    y with copies of it.
    I suggest that you study the "Performance and Memory Management" chapter of the LabVIEW manual. This can found in the printed manual of the older versions, in the online manuals that install with 6i, or on NI's web site here: http://zone.ni.com/devzone/conceptd.nsf/2d17d611efb58b22862567a9006ffe76/732cec772aa4fbe586256a37005541d3?OpenDocument , which is Application Note 168. This should give you some good ideas of what to look for to improve your performance.
    Hope this helps.
    Brian

Maybe you are looking for