Tutorial, ActionScript 3, Using Shared Objects to show the time of page browsing

Here is my first tutorial at FlashDaWeb.
I will show how SharedObject might be used.

For illustration, I came up with an idea to show users the time they spend browsing a particular page.

Here is an example.

Open this demo page and see the timer, then close it and open again anytime you want. Notice, time will not start again from 0:0, it will continue counting from the very values you previously closed it. Quite nice, isnt it?

In your hands.

The above functionality was implemented with Adobe Flash CS3, ActionScript 3 and SharedObject.

For this tutorial I assume you already know the basics of AS3 and are quite acquainted with Flash CS IDE.

I created a new document and added new movie clip. Its named mainObject. I put one instance of it at stage and linked it to the actionscript class SharedObjectReader.as

In our class, we have a member of shared object:

private var _sharedObj:SharedObject;

In constructor of our class, we create children and start actionscript timer-based cycle using setInterval.

public function SharedObjectReader ()
{
createChildren();

//load and update the correct values
onEverySec();

//update the values every second
setInterval(onEverySec,1000);
}

In onEverySec method we bind our _sharedObj to a local instance with static method getLocal(), put it in try-catch block to handle the exceptions.TotalTimeAtThisPage is a name of Shared Object, you may use anything in there.

» Description:
I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all

» Description:
Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.