Groups | Blog | Home
all groups > flash actionscript > june 2004 >

flash actionscript : Need Help! How To Create a Button Hits Counter?


DonnoW
6/7/2004 9:00:53 PM
I have a button and I want to create a counter that show the number of the hits of the button...
elemental .std
6/7/2004 9:09:34 PM
You have to use PHP or Perl to save changes into file.
See www.flash-db.org
There is an example of site counter but you can easily rewrite it into button counter.

Best Regards
DonnoW
6/7/2004 9:12:49 PM
tnx man...but look...
i don't want it to save after the movie closed...
elemental .std
6/7/2004 9:18:48 PM
oh

then use this script
_root.counter = 0;
_root.button.onPress = function() {
_root.counter++;
}

Place this script in the stage movie.
_root.button is the path to your button.
This script will var Counter = 0 and then when Button is pressed Counter will
be increaced by 1.


DonnoW
6/7/2004 9:24:00 PM
elemental .std
6/7/2004 9:31:12 PM
Create Dynamic text field and set its variable to be _root.counter.
DonnoW
6/7/2004 9:43:20 PM
k....the dynamic text is workin'....it's show the number 0....
but...in the first script...

let say the instance name of the button is: gun

what should i change here:

_root.counter = 0;
_root.button.onPress = function() {
_root.counter++;
}

?


DonnoW
6/7/2004 9:43:34 PM
k....the dynamic text is workin'....it's show the number 0....
but...in the first script...

let say that the instance name of the button is: gun

what should i change here:

_root.counter = 0;
_root.button.onPress = function() {
_root.counter++;
}

?


elemental .std
6/7/2004 9:49:36 PM
DonnoW
6/7/2004 9:52:58 PM
tnx bro!!!!! it's all working!!! man 10XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX!!!
U REALLY HELPED ME!!!
craig andrews_99
10/15/2004 12:54:35 PM
kglad
10/15/2004 2:57:16 PM
if your textfield has instance name tbox you can use:

_root.counter = 0;
_root.yourButton.onPress = function() {
_root.counter++;
tbox.text=_root.counter;
AddThis Social Bookmark Button