Blog Post RSS ?

Blogs » Flash » Quickie: Shared Object Fiddling
 

Quickie: Shared Object Fiddling


  • Save to
    Del.icio.us

by sgrosvenor

Personal Hit Counter Shared Object Example >>

Messing around with code in Flash MX / MX 2004 can produce some interesting results, some more useful than others, and in this case a quick and dirty personal hit counter for the number of times you have visited the site you implement the code on, along the lines of ‘You have been here xx times’ using the Shared Object.

Whilst displaying the result of the following code may seem a trite overboard, it does have uses and implementations; for example…

You could easily trigger functions to be called using a simple switch statement allowing you to conditionally display information based on the number of times a user has been to the site

You could change the navigation structure to suit the needs of the user based upon their click habits; the list goes on…so feel free to experiment

sObjVisits = SharedObject.getLocal("userVisitsLocal"); if (sObjVisits.data.visits == undefined) { sObjVisits.data.visits = 1; } else { sObjVisits.data.visits = sObjVisits.data.visits+1; } howManyVisits = sObjVisits.data.visits; sObjVisits.flush(); visits.text = "been here "+howManyVisits+" times";

This post has 7 responses so far

  1. How can I count total visits Num?Thanks a lot.

     
  2. How can I count all visits number.
    thanks

     
  3. Well, that requires scripting to store the variables on the web server itself, either in a text file or database, here is an example of a PHP/mySQL hit counter

    PHP/mySQL Hit Counter in Flash >>

     
  4. You have to think of the Flash Share Object as a client cookie, because it effectively create a file in the client system, and nothing on the server side…I use it here to save various variables as well as a text !

     
  5. And what’s the minimum Flash Player requirement for using Shared Objects? v7?

     
  6. Nope, the Shared Object was available in Flash MX for design,and for playback Player v6

     
  7. Question: is it possible to write a .time or .date to SO’s? I found this article for how to do it in ActionScript 3 (in CS3).

    Know any way to do it???

     

Sponsored Links

Leave a response

You are not logged in, log in with your SitePoint Forum username and password.

-OR- Post Anonymously

* Make sure any code samples are escaped (i.e. ‘<b>’ becomes ‘&lt;b&gt;’).

If not logged in, your comments will be placed in a moderation queue. This means your comment may not appear until one of our moderators approves it.

SitePoint Marketplace

Buy and sell Websites, templates, domain names, hosting, graphics and more.

Logo Design, Web page Design and more!

99designs

  • Custom logo designs created ‘just for you’.
  • Pick the design you like best.
  • Only pay if you’re satisfied with the result.

It's Back!
FREE PDF with any printed book!