Go back to school with your Mac, iPhone and TUAW

Shared Objects for Returning Visitors

Shared Object CodeA common question on the Flash boards I hang out on is how to deal with return visitors to your Flash site. After all, the goal is usually to have folks come back to your site and come back often. But how do you keep your content from being a barrier? How often should your visitors have to watch that site intro movie (as brilliant as it is!)? The answer is probably once.

Even with the ubiquitous “Skip Intro” button, many visitors will be turned off having to deal with the same intro movie every time they visit a site. Why make them have to click-to-skip when, with a little forethought, you can take care of this and make your site look that much smarter?The answer is in the Shared Object. Shared Objects are basically Flash cookies, a small text file dropped onto your visitor’s computer which you can then reference later. By putting the following code in the first frame of your movie, you’ll initialize a new Shared Object, check to see if that object exists on the current computer and act accordingly (play the intro animation if the user is new, skip it if they’ve been to the site before):
//initialize the shared object – get it if it exists on this computer
var my_so:SharedObject = SharedObject.getLocal("visited", "/");

//check to see if the visited info object exists and act accordingly
if (my_so.data.newVisitor != undefined) {
  //object exists: return user
  //replace "frame-for-return-user" with the frame number that skips your intro animation
    this.gotoAndPlay(frame-for-return-user);
} else {
   //object doesn't exist: new user
   //set the newVisitor attribite of the my_so.data object to indicate this is not a new visitor next time they come to the site
    my_so.data.newVisitor = "no";
    this.play();    
}
Actually, it doesn't really matter what value you give to “newVisitor” here. For our purposes, we're just checking to see that the object exists. You can get a lot more complex by setting the attribute to different values and acting according to that value.

You could even add attributes and customize your movie! Have your visitors put their name into an input text field and save it as part of the Shared Object; the next time they visit, customize the greeting by writing the value back to a text field, “Welcome back, Bob!”

The Shared Object has some limitations (a default of a 100k file size limit without the user’s input), but they can be really useful in making your visitors’ experience a lot more personal. Make ‘em feel at home! And keep ‘em coming back!

Reader Comments

(Page 1)
News
Macromedia (141)
Innovation (164)
Merger (41)
Releases (65)
WIN Business (24)
Events
MAX (26)
FlashForward (8)
MMUGs (16)
Webinars (4)
Learning
ActionScript (49)
Designer Certification (5)
Developer Certification (6)
Ideas (163)
Links (83)
Samples (57)
Tips and Tricks (98)
Tutorials (45)
Design & Development
Accessibility (14)
Ad Design (27)
Art (94)
Components (6)
Extensions (17)
Games (65)
Rich Internet Applications (99)
Sound (38)
Video (65)
Web Standards (33)
Software
Flash 8 (103)
Flash MX2004 (92)
Flash Paper 2 (3)
Flash Player 8 (55)
Flash MX2004 Professional (44)
Flash Lite (24)
Flash Platform (91)
Flash Remoting (3)
Flash Communications Server MX (8)
Flash Video (24)
Flash Paper (3)
Macromedia Contribute (2)
Macromedia Flex (8)
8Ball (15)
Maelstrom (19)
Software Updates (34)
Beta (22)
Bugs (14)
Studio 8 (25)

RESOURCES

RSS NEWSFEEDS

Powered by Blogsmith

Other Weblogs Inc. Network blogs you might be interested in: