How can I ignore multiple clicks while processing the first one?

Hi -
I am writing my first Flex program so I'm sorry if this is a newbie question.
I have some code which handles a click but takes a while to finish. What I want to do is proces steh first click but ignore any more clicks until the code has finished dealing with the first one.
Can anyone tell me the standard way to do this?
Here's a simplified example with a builtin delay. If I click on the button several times and then wait, the clicks are all processed in sequence and the test count slowly increases. What I want the code to do is ignore any clicks which teh user made during the two second delay but start handling new clicks after the delay has finished.
Example Code...
<<?xml version="1.0"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx">
   <fx:Script>
      <![CDATA[
private var count:Number = 0;
private function clickHandler():void {
   // Something which takes a while to complete...
   var timer:Date = new Date();
   while( (new Date()).valueOf() - timer.valueOf() <  2000 ) {
      var nop:int = 0;
   // Report result
   count++;
   output.text="Test Number "+count;  
]]>
   </fx:Script>
   <s:Panel title="Example">
      <s:VGroup left="10" right="10" top="10" bottom="10">
           <s:Label id="output" text=""/>
           <s:Button label="Click Me" click="clickHandler();"/>
      </s:VGroup>
   </s:Panel>
</s:Application>
Thanks
- Jon

Thanks for the response Pramod. I tried to disable and enable the button but it doesn't seem to have any effect at all. If I click the button several times, this code still processs the clicks one at a time over the next few seconds. I am sure I am making a simple mistake somewhere here...
private function clickHandler():void {
   mybutton.enabled = false;
...slow stuff here
   mybutton.enabled = true;
Full code...
<?xml version="1.0"?><s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"      xmlns:s="library://ns.adobe.com/flex/spark"      xmlns:mx="library://ns.adobe.com/flex/mx">   <fx:Script>      <![CDATA[ private var count:Number = 0;  private function clickHandler():void {   mybutton.enabled = false;    // Something which takes a while to complete...   var timer:Date = new Date();   while( (new Date()).valueOf() - timer.valueOf() <  2000 ) {      var nop:int = 0;   }     // Report result   count++;   output.text="Test Number "+count;       mybutton.enabled=true;}  ]]>   </fx:Script>     <s:Panel title="Example">      <s:VGroup left="10" right="10" top="10" bottom="10">         <s:Label id="output" text=""/>         <s:Button id="mybutton" label="Click Me" click="clickHandler();"/>      </s:VGroup>   </s:Panel>  </s:Application>                         

Similar Messages

  • How can i create multiple accounts but use the same itunes?

    how can i create multiple accounts but use the same itunes?

    Hi iCloud is Making Me Go Crazy,
    You will need to create a new Apple ID for your GameCenter and iCloud services.  You can continue to use the current Apple ID you share with your Mom for access to iTunes Store purchases if you wish. 
    Using your Apple ID for Apple services
    http://support.apple.com/kb/HT4895
    Frequently asked questions about Apple ID
    http://support.apple.com/kb/HT5622
    Cheers,
    - Judy

  • How can I print multiple copies of same photo onto one page on iPhoto 9.5.1?

    How can I print multiple copies of same photo onto one page on iPhoto 9.5.1? I was able to do it on the old iPhoto, but can't seem to be able to do it on the new iPhoto. Grrr...

    Photos does the same thing.... Only workaround I can come up with is to create a template in Pages and copy &amp; paste.

  • How can I select multiple photos without tapping on each one individually

    How can I select multiple photos without tapping on each one individually?

    Op: without tapping on each one individually
    tap all the photos you want to delete.
    Note what the OP is asking.

  • How can I create multiple sales orders with reference to one contract?

    Hello Gurus,
    Can you please how can I create multiple sales orders with reference to one contract?
    thanks!
    Rakesh

    hi
    Lets consider example
    In your contract for line item 1 you have entered qty 100
    You careated sales order with 70 quantity, and now you want to creat another sales order for 30
    For this first you need to check what is your item category in contract (VA42)
    Goto VOV7
    SPRO - IMG  - Sales and distribution - Sales - Sales document item - Define item categories - Go to change mode
    Make the completion rule = B Item is completed after full quantity has been referenced

  • How do you download all chapters of a video at once?  I purchased a yoga video with multiple chapters and only the first one loaded.  It says I can't download another chapter for 90 days.

    I purchased a yoga video with multiple chapters and only the first one loaded.  It says I can't download another chapter for 90 days.  How do I get all chapters to download?

    Once a device or computer is associated with your Apple ID, you cannot associate that device or computer with another Apple ID for 90 days.
    http://support.apple.com/kb/ht4627

  • How can I insert multiple page contents in the page layout properly?

    I wanted to create 4 columns on the page layout. These 4 columns are of page contents.
    After creating new web page based on that page layout, I attempted to enter 4 different inputs on all 4 columns.
    Then, the result (from all columns) becomes the same.
    Image - edit the web page based on 4 columns page layout:
    Image - after edit & save:
    How can I insert multiple page contents in the page layout properly?

    First, I copied the HTML snippet for the Page Content on Sharepoint's Design Manger. The code of Page Content HTML snippet is shown below:
    <div data-name="Page Field: Page Content">
    <!--CS: Start Page Field: Page Content Snippet-->
    <!--SPM:<%@Register Tagprefix="PageFieldRichHtmlField"
    Namespace="Microsoft.SharePoint.Publishing.WebControls"
    Assembly="Microsoft.SharePoint.Publishing, Version=15.0.0.0,
    Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>-->
    <!--MS:<PageFieldRichHtmlField:RichHtmlField
    FieldName="f55c4d88-1f2e-4ad9-aaa8-819af4ee7ee8" runat="server">-->
    <!--PS: Start of READ-ONLY PREVIEW (do not modify)-->
    <div id="ctl02_label" style="display:none">Page Content</div>
    <div id="ctl02__ControlWrapper_RichHtmlField" class="ms-rtestate-field"
    style="display:inline" aria-labelledby="ctl02_label"><div align="left"
    class="ms-formfieldcontainer"><div class="ms-formfieldlabelcontainer"
    nowrap="nowrap"><span class="ms-formfieldlabel"
    nowrap="nowrap">Page Content</span></div>
    <div class="ms-formfieldvaluecontainer"><div class="ms-rtestate-field">
    Page Content field value. Lorem ipsum dolor sit incididuntet dolore.</div>
    </div></div></div><!--PE: End of READ-ONLY PREVIEW-->
    <!--ME:</PageFieldRichHtmlField:RichHtmlField>-->
    <!--CE: End Page Field: Page Content Snippet-->
    </div>
    After I published the page layout, I found the code for Page Content from its ASPX page. The code is shown below:
    <div data-name="Page Field: Page Content">
    <PageFieldRichHtmlField:RichHtmlField FieldName="f55c4d88-1f2e-4ad9-aaa8-819af4ee7ee8" runat="server"/></div>
    So, I attempted to create 4 columns by using 4 HTML snippets of Page Content on the same page layout. The page layout is generated from HTML file to ASPX file.
    Then I edited some parts in ASPX page layout:
    <asp:Content runat="server" ContentPlaceHolderID="PlaceHolderMain">
    <table>
    <tr>
    <td style="width:70px;">&nbsp;</td>
    <td style="width:250px; text-align:right;">
    <div data-name="Page Field: Page Content">
    <PageFieldRichHtmlField:RichHtmlField FieldName="f55c4d88-1f2e-4ad9-aaa8-819af4ee7ee8" runat="server"/>
    </div>
    </td>
    <td style="width:40px;">&nbsp;</td>
    <td style="width:200px;">
    <div data-name="Page Field: Page Content">
    <PageFieldRichHtmlField:RichHtmlField FieldName="f55c4d88-1f2e-4ad9-aaa8-819af4ee7ee8" runat="server"/>
    </div>
    </td>
    <td style="width:25px;">&nbsp;</td>
    <td style="width:200px;">
    <div data-name="Page Field: Page Content">
    <PageFieldRichHtmlField:RichHtmlField FieldName="f55c4d88-1f2e-4ad9-aaa8-819af4ee7ee8" runat="server"/>
    </div>
    </td>
    <td style="width:25px;">&nbsp;</td>
    <td style="width:200px;">
    <div data-name="Page Field: Page Content">
    <PageFieldRichHtmlField:RichHtmlField FieldName="f55c4d88-1f2e-4ad9-aaa8-819af4ee7ee8" runat="server"/>
    </div>
    </td>
    <td style="width:175px;">&nbsp;</td>
    </tr>
    </table>
    </asp:Content>
    The 4 columns for Page Contents appeared on the web page when I created new page using that page layout. But the problem is that all 4 columns displayed the same result from 4th column.

  • How can I add new games without overwriting the old ones?

    I have just purchased two new games in the itunes store and although they are showing in the library (under applications) my previously purchased games are not. In Summary under games it will not let me choose selected games only 'all games' and when I press sync warns that the existing games will be replaced. How can I add these games without deleting the older ones? Also if I did want to remove a game from my ipod how do I do it?

    hardlyquinn wrote:
    Part of the problem is that I can never sync the whole thing as I dont keep all my music in my library (it seems silly to have my enture cd collection on the computer).
    Clearly it ISN'T silly as it avoid issues like you are having right now. If you need more space, get an external hard drive. To me it is much sillier to only have your stuff on the iPod and no where else as the iPod, as a small portable player, is much more likely to be dropped, lost, damaged, stolen, forgotten somewhere, etc.
    While I am not familiar with the use of games on the iPod (I have never bought any) you can switch the iPod to manually manage and then you can add content to your iPod without losing what is already there. Perhaps it works for games as well.
    But long term, I strongly suggest you keep all your stuff in your library so if you need to (you have to perform a restore on the iPod, you lose it and buy a new one, etc.) you can very easily sync it all back to the iPod when needed.
    Good luck,
    Patrick

  • I cant remember my password to logon to my mac, how can i change it with out needing the old one?

    i cant remember my password to logon to my mac, how can i change it with out needing the old one?

    http://support.apple.com/kb/HT1274

  • When I save my book in iBooksAuthor as .ibooks, it does not open on the Intro Media page.  How can I be sure it opens on the first page?

    When I save my book in iBooksAuthor as .ibooks, it does not open on the Intro Media page.  How can I be sure it opens on the first page?

    hello suffaman46, please refer to the documentation provided by yahoo for this issue: http://help.yahoo.com/kb/index?locale=en_US&y=PROD_ACCT&page=content&id=SLN2896

  • I loos my APPLE ID, I have a new one, how can get access to data stored in the old one?

    I loos my APPLE ID, Now I have a new one, how can get access to data stored in the old one?

    Do you have the email & password of the old Apple ID?

  • I have a basic photography plan.  How can I upgrade my storage while keeping the plan?

    My name is Joseph Ryan.  I currently have a photography plan that's for $10 a month with only 2gb of storage.  How can I increase my storage without upgrading the plan?

    I shall be assisting you regarding this to increase the storage space, I shall be informing you once completed.
    Regards
    Rajshree

  • How can I get new iphone I broke the other one

    How can I get new iphone I broke the other one

    What do you mean "you broke it"?
    If you dropped it you can make a Genius Bar appointment at your nearest Apple Store and do an out-of-warranty replacement for $269 USD.

  • Can't edit any editable region but the first one!

    I have a CSS layout and I am trying to edit documents that
    are based on a template that has CSS only layout, the only Editable
    Region I can edit from within Dreamweaver seems to be the first
    one, with a Flash object in it, all the other ones I can
    double-click until I am blue in the face and I cannot get DW to let
    me into edit the area, it's driving me crazy.
    What can I do to fix this!
    Please help.

    Show me the template, please.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "edoggie" <[email protected]> wrote in
    message
    news:eak466$54e$[email protected]..
    >I have a CSS layout and I am trying to edit documents
    that are based on a
    > template that has CSS only layout, the only Editable
    Region I can edit
    > from
    > within Dreamweaver seems to be the first one, with a
    Flash object in it,
    > all
    > the other ones I can double-click until I am blue in the
    face and I cannot
    > get
    > DW to let me into edit the area, it's driving me crazy.
    >
    > What can I do to fix this!
    >
    > Please help.
    >
    >

  • Module web app list tags - how to start a list to not include the first one?

    Hi
    I have two panels displaying a web app list and want them to follow on from each other, so panel one displays the first one {module_webapps,24027,l,,,,false,1,false,1} and then the second panel displays the 2nd and 3rd.
    How would I go about it?
    Thanks
    J-P

    Hello
    Hope the below helps
    http://prasantabarik.wordpress.com/2013/09/26/pass-querystring-value-from-sharepoint-page-to-app-partclient-web-part/
    Please remember to click 'Mark as Answer' on the answer if it helps you

Maybe you are looking for

  • Form with report, update field in the form = field is not updated in table

    Hi, I have a form with report. On Primary Key in the report is a link to the form. I select one row in the form by choosing the link in the report. Then I update a field in the form and press "Save". I see the success message "Action processed" and I

  • Cannot turn on AirPort after Snow Leopard upgrade with Parallels 3

    Since I have upgraded to Snow leopard, my wifi does not turn on, I have seen some comments about parallels causing the problem, does anyone know if this is true and if so how to turn of the ports they are using. I cannot open the parallels environmen

  • Log and Transfer Causes FCP to Freeze!

    Quite an annoying problem. Running FCP 6.0.6 I go to log & transfer new footage. I can select a folder. I can even see the footage and play it back in the preview window, but when I press "Add Selection to Queue" or "Add Clip to Queue" (both do this)

  • Need help with Error #2044: Unhandled securityError:.

    Hi, I am developing an AIR+AJAX app and I am using sockets to connect to the ftp server and just checking whether the app is able to connect to the ftp server successfully, check the user name and password and return with a message. It connects and d

  • NT Service can't connect

    I've written a piece of software that uses an ODBC connection to an 8.1.7 database. Driver version is 8.1.72. When I execute the software the connection works correctly. When I register the software an an NT Service, and use the exact same connection