A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: clicks per second

  1. #1
    Junior Member
    Join Date
    Dec 2005
    Posts
    28

    clicks per second

    i need a fla file that shows the clicks per second some one is getting. any help?

  2. #2
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hi,

    If strict accuracy is not neccessary,this will probably work. It is based on a setInterval call of 1000 milliseconds....

    code:

    clickCount = 0;
    _root.onMouseDown = function() {
    clickCount++;
    }
    function countTrack() {
    trace(clickCount+" clicks per second");
    clickCount = 0;
    }
    traceCount = setInterval(countTrack, 1000);


  3. #3
    Junior Member
    Join Date
    Dec 2005
    Posts
    28
    cool. thanks. will that display to the user the amount of clicks he has?

  4. #4
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    no, that just traces the value to the output window for testing. You would need to create a textfield and assign the variable to the text property of the textfield...

    myTextfield.text=clickCount+" clicks per second";

  5. #5
    Junior Member
    Join Date
    Dec 2005
    Posts
    28
    ok it displays "0 clicks per second" but the 0 wont change
    Last edited by sk8rjess; 12-10-2005 at 08:33 PM.

  6. #6
    Junior Member
    Join Date
    Dec 2005
    Posts
    28
    and then, how would i display the highest click the person has?

  7. #7
    Junior Member
    Join Date
    Dec 2005
    Posts
    28
    grrr i just cant get it to work!

  8. #8
    Senior Member hum's Avatar
    Join Date
    Sep 2003
    Location
    CloudCuckooland
    Posts
    1,714
    Hi
    NTD's example shows a function that has a setInterval action which every second records how many clicks occur then resets the clickCount variable back to ...0....after the interval has occured.....

    If you just need to know how many clicks occur....you could create a dynamic text box and call it ....howManyClicks....for example
    Then put this in the timeline....
    code:
    howManyClicks = 0;
    _root.onMouseDown = function() {
    howManyClicks += 1;
    };

    Last edited by hum; 12-11-2005 at 03:21 PM.

  9. #9
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hi,

    code:

    clickCount = 0;
    _root.createTextField("myTextField", 1, Stage.width/2, Stage.height/2, 150, 20);
    myTextField.background = true;
    _root.onMouseDown = function() {
    clickCount++;
    }
    function countTrack() {
    trace(clickCount+" clicks per second");
    myTextfield.text = clickCount+" clicks per second";
    clickCount = 0;
    }
    traceCount = setInterval(countTrack, 1000);



  10. #10
    Junior Member
    Join Date
    Dec 2005
    Posts
    28
    thanks guys... but i dont think i explained what i ment. i need it to display how many clicks per second the person is getting, and then in another text box, display the most clicks per second the user has had.

  11. #11
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    code:

    clickCount = 0;
    _root.createTextField("myTextField", 1, Stage.width/2, Stage.height/2, 150, 20);
    _root.createTextField("totalTextField", 2, Stage.width-150, Stage.height/2, 150, 20);
    myTextField.background = true;
    totalTextField.background = true;
    _root.onMouseDown = function() {
    clickCount++;
    if (clickCount<highCount) {
    highCount = highCount;
    } else {
    highCount = clickCount;
    }
    }
    function countTrack() {
    trace(clickCount+" clicks per second");
    myTextfield.text = clickCount+" clicks per second";
    totalTextField.text="Fastest clicks per second="+highCount;
    clickCount = 0;
    }
    traceCount = setInterval(countTrack, 1000);

    Last edited by NTD; 01-25-2006 at 05:36 AM.

  12. #12
    Junior Member
    Join Date
    Dec 2005
    Posts
    28
    i got these errors with that:

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 17: ')' expected
    highCount = highCount;

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 20: 'else' encountered without matching 'if'
    else {

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 26: Unexpected '}' encountered
    };

    Total ActionScript Errors: 3 Reported Errors: 3

  13. #13
    Senior Member hum's Avatar
    Join Date
    Sep 2003
    Location
    CloudCuckooland
    Posts
    1,714
    Hi
    code:
    clickCount = 0;
    _root.createTextField("myTextField", 1, Stage.width/2, Stage.height/2, 150, 20);
    _root.createTextField("totalTextField", 2, Stage.width-150, Stage.height/2, 150, 20);
    myTextField.background = true;
    totalTextField.background = true;
    _root.onMouseDown = function() {
    clickCount++;
    if (clickCount < highCount) {
    highCount = highCount;
    } else {
    highCount = clickCount;
    }
    };
    function countTrack() {
    trace(clickCount+" clicks per second");
    myTextfield.text = clickCount+" clicks per second";
    totalTextField.text = "Fastest clicks per second="+highCount;
    clickCount = 0;
    }
    traceCount = setInterval(countTrack, 1000);


  14. #14
    Junior Member
    Join Date
    Dec 2005
    Posts
    28
    hmmm alright well thanks for all your alls help but once again, i need help. this is what i have sofar
    Code:
    clickCount = 0;
    
    _root.createTextField("myTextField", 1, Stage.width/2, Stage.height/2, 150, 20);
    
    _root.createTextField("totalTextField", 2, Stage.width/2, Stage.height/2, 150, 20);
    
    myTextField.background = false;
    
    totalTextField.background = false;
    
    _root.onMouseDown = function() {
    
    	clickCount++;
    
    	if (clickCount < highCount) {
    
    		highCount = highCount;
    
    	} else {
    
    		highCount = clickCount;
    
    	}
    
    };
    _root.onMouseUp = function() {
    
    	clickCount++;
    
    	if (clickCount < highCount) {
    
    		highCount = highCount;
    
    	} else {
    
    		highCount = clickCount;
    
    	}
    
    };
    
    function countTrack() {
    
    	trace(clickCount+" shots per second");
    
    	myTextfield.text = clickCount+" ";
    
    	totalTextField.text = ""+highCount;
    
    	clickCount = 0;
    
    }
    
    traceCount = setInterval(countTrack, 1000);
    how would i make it like, after the user hits 10 shots per second, it would double how many it adds to each click. heh please help, i am absolutely clueless

  15. #15
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hi,

    Can you actually achieve 10 clicks per second? Anyway, you could use an if statement to check if the highcount variable is greater than 10. Something like....

    code:

    if(clickcount>10&&clickcount>highcount){
    clickcount+=2;
    }else{
    clickcount++;
    }


  16. #16
    Junior Member
    Join Date
    Dec 2005
    Posts
    28
    it doesnt do anything, i have:
    Code:
    clickCount = 0;
    
    _root.createTextField("myTextField", 1, Stage.width/2, Stage.height/2, 150, 20);
    
    _root.createTextField("totalTextField", 2, Stage.width/2, Stage.height/2, 150, 20);
    
    myTextField.background = false;
    
    totalTextField.background = false;
    
    _root.onMouseDown = function() {
    
    	clickCount++;
    
    	if (clickCount < highCount) {
    
    		highCount = highCount;
    
    	} else {
    
    		highCount = clickCount;
    
    	}
    
    };
    _root.onMouseUp = function() {
    
    	clickCount++;
    
    	if (clickCount < highCount) {
    
    		highCount = highCount;
    
    	} else {
    
    		highCount = clickCount;
    
    	}
    
    };
    
    function countTrack() {
    
    	trace(clickCount+" shots per second");
    
    	myTextfield.text = clickCount+" ";
    
    	totalTextField.text = ""+highCount;
    
    	clickCount = 0;
    
    }
    
    traceCount = setInterval(countTrack, 1000);
    if(clickcount>10&&clickcount>highcount){
    
    clickcount+=2;
    
    }else{
    
    clickcount++;
    
    }

  17. #17
    Junior Member
    Join Date
    May 2005
    Posts
    7
    I know what you are doing
    You are making a paintball game to see who can shoot the fastest. I guess you do not like the ego or dm5 versions floating around huh However, there are already 2-3 good ones out there. He is basically wanting this:
    Shows how many shots per second you can achieve. It keeps track of the highest shot per second average you achieve in a seperate window. The highest I can achieve without cheating is 19 bps.

  18. #18
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hi,

    I am not sure what exactly is trying to be done here, but the code I posted works correctly for FlashMX. What version of Flash are you using?

  19. #19
    Junior Member
    Join Date
    Dec 2005
    Posts
    28
    lol phantomhitman, yea i am. i haave had one done for a while but now i would like to do one with ramping. Im using Flash MX 2004 Pro

  20. #20
    Junior Member
    Join Date
    Dec 2005
    Posts
    28
    hmmm. i have been looking at this, and i understand what everything does, but im clueless why it isnt working

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