Shared Objects in Flex

How nice it would be to welcome back or to recognize visitors who are revisiting your website or application. Adobe Flex provides ways to store objects in clients machine, and implementing does not compromise any issues on security of the client’s machine.

The Behaviour of shared objects is somewhat like a cookie. The class can be used to store data on the clients machine and retrive those objects in same session or in another session. The declaration part is as simple like Arrays , String or Date. You are also allowed to create multiple instance in one application and each instance is associated with a name to identify.Don’t worry readers, at the end i will provide you with an example.

private function visitingInfo():void
{
var dateInfo:SharedObject = SharedObject.getLocal(”userVisitedDate”);
trace(“SharedObject is ” + dateInfo.size + ” bytes”);
if(dateInfo.data.lastVisitedDate != null)
{
Alert.show(”Welcome back, you visited last on ” + dateInfo.data.lastVisitedDate);
}
dateInfo.data.lastVisitedDate = new Date();
dateInfo.flush();
}

Let me explain the code to you in brief. Initially we are creating a variable of return type sharedObject. The getLocal method tried to load a local shared Object with the name lastVisitedInfo. If there is no name, then a new object is created. Now in the coming line, we are checking whether it is is NULL and displaying an appropriate message. The final line is makes sure that your object is saved.

Popularity: 1% [?]

About the Author

Vinothbabu has written 24 stories on this site.

In short, my name is Vinoth babu { perra kettala summa authrithala } a UI expert from India, Chennai.

Write a Comment

Gravatars are small images that can show your personality. You can get your gravatar for free today!

Copyright © 2010 HTTPguru. All rights reserved.

Our Partners:
WebHosting Jobs| UI expert | Packet Sniffer  | Mobile Home Refinancing  | Laptop LCD screens | CSS Creator| Exchange Hosting| Compare cable companies| Usa online casino | vps | Coupon Codes