Solved

Hit counter for a flash document

Posted on 2001-07-30
14
259 Views
Last Modified: 2006-11-17
HI:

I have a flash file in wich i want to put a hit counter, i'm an asp developer and i don't know php language, and the hot in wich i have my site hosted is a unix, and i need make a hit counter in php and then pass the value to my swf file.

some of you can help me with the code and the way to do it?
thank's....i'm hearing
0
Comment
Question by:kinezul
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
14 Comments
 

Expert Comment

by:Bungee
ID: 6338959
do you need session to track a user or do you just want to know how many users have visited your site ?

Bungee
0
 

Author Comment

by:kinezul
ID: 6345154
i need to know the number of visitors only.
0
 

Expert Comment

by:cynicz
ID: 6352068
write a short wrapper around the flash file:

bumpTheCount();
# increment the number. don't know how you
# want to store the count...

header('Content-type: application/x-shockwave-flash');
$fd = fopen('foo.swf','r');
while($chunk = fread($fd, 4096)){
    echo $chunk;
}
fclose($fd);

and then instead of pointing the visitor directly to the flash file, point them to the wrapper script.
0
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
LVL 1

Expert Comment

by:rumblefiz
ID: 6353941
you could also use load variables from within flash and then point it to your php script. this is the same way you would do it with asp except your php script might look something like:

<?
   ## get_the_count func could read a cookie or from a db or whatever
      $iCount = get_the_count();
      $sReturn = urlencode("The count is: $iCount");
      echo $sReturn;
?>

note ** on some flash to get it to work i had to use rawurlencode() instead of urlencode().

hope this helps. this way you could animate it and stuff. let me know if you need an example and i will see if i can send you one real quick.

rumblefiz
0
 
LVL 1

Expert Comment

by:rumblefiz
ID: 6366156
kinezul -

are you ok now? did any of these help?

- rumblefiz
0
 

Author Comment

by:kinezul
ID: 6369003
rumblefiz :

Could you send me an example?, and i can give to you 200 points

Thanks
0
 
LVL 1

Expert Comment

by:rumblefiz
ID: 6369038
sure. i will put one together real quick. where should i e-mail it?

- rumblefiz
0
 

Author Comment

by:kinezul
ID: 6369068
put here !: afranco@ga.com.mx
0
 
LVL 1

Expert Comment

by:rumblefiz
ID: 6369076
i will put the php code here, i have to e-mail you the flash file. i will also send you a link of it working on my server. give me a couple minutes to finish with this conf call and i will send it right over.

- rumblefiz
0
 

Author Comment

by:kinezul
ID: 6369099
thanks, if you can tell me de rigth way to configure it, will be good
0
 
LVL 1

Expert Comment

by:rumblefiz
ID: 6369191
actually, rather than me typing up a bunch of instructions and a sample file, take a look at the following url. there is a simple counter that pretty much does the same exact thing as i am talking about. it uses a text file to store the number of hits. remember to give write permissions on the txt file so the count will increment.

http://flashplanet.com/body_advanced.html

no point in retyping something that somone else already did! hope this helps.

- rumblefiz
0
 
LVL 1

Expert Comment

by:rumblefiz
ID: 6369214
if you cant get it to work i will be glad to see if i can help. i did a quick search and found this link. i figured this way you could get started (didn't know how urgent this is). i can't seem to get off this darn conf call ;)

let me know if you need some help.

- rumblefiz
0
 
LVL 1

Accepted Solution

by:
rumblefiz earned 150 total points
ID: 6369225
one thing that i forgot to correct from my above post is that you need to specify the var in the return so that flash knows what to set. above i typed:

$sReturn = urlencode("The count is: $iCount");

it should be:

$sReturn = "myVarInFlash=".urlencode("The count is: $iCount");

- rumblefiz

0
 

Author Comment

by:kinezul
ID: 6375508
Thank's for all
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question