A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Button count and timer?

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    9

    Button count and timer?

    Is it possible for me to create a button that must be clicked 4 times within 3 seconds to call a function? How would i go about this?

    Thanks, Troy.

  2. #2
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    there are many different ways you could do this. here's one:

    PHP Code:
    button.addEventListener(MouseEvent.CLICKquadClickfalse0true);

    var 
    clickCount:uint 0;
    var 
    timer:Timer = new Timer(3000);
    timer.addEventListener(TimerEvent.TIMERstopQuadClickfalse0true);

    function 
    stopQuadClick(event:TimerEvent):void{
        
    button.removeEventListener(MouseEvent.CLICKcountClicks);
        
    button.addEventListener(MouseEvent.CLICKquadClickfalse0true);
        
    timer.stop();
    }

    function 
    quadClick(event:MouseEvent):void{
        
    clickCount 0;
        
    timer.start();
        
    button.removeEventListener(MouseEvent.CLICKquadClick);
        
    button.addEventListener(MouseEvent.CLICKcountClicksfalse0true);
    }
    function 
    countClicks(event:MouseEvent):void{
        
    clickCount++;
        if(
    clickCount == 3){
            
    trace("clicked 4 times in 3 seconds");
            
    stopQuadClick(null);
        }


  3. #3
    Junior Member
    Join Date
    Dec 2010
    Posts
    9
    thank you very much Moagrius! Works great!

  4. #4
    ___________________
    Join Date
    May 2004
    Posts
    3,174

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center