Photoshop Tutorials, Flash Tutorials, 3Ds Studio Max Tutorials, Web Design Tutorials

Home  |  Submit Tutorial  |  Top Sites  |  Free Templates (NEW)  |  Website templates  |  Privacy Policy  |  Link Exchange  |  Contact Us

Recommended Hosting:
Host Unlimited Domains on 1 Account
1500GB storage and 15000GB bandwidth for $6.95/mo!
Recommended Hosting:
Host Unlimited Domains on 1 Account
1500GB storage and 15000GB bandwidth for $6.95/mo!

Welcome To ProDesignHost.com Flash Tutorials Area - SharedObject and You

Hi and welcome to this tutorial. This tutorial covers SharedObject. SharedObject is a kind of cookie for Flash. Though, SharedObject is much more powerful. SharedObject isn't just a way of saving mere strings on the client's hard disk, you can store texts, strings, numbers and even objects. For instance, if you want to save a date object in JavaScript you would have to go though a whole encoding process, with SharedObject you just save it, and be ready.

Starting with SharedObject

SharedObject is pretty simple to work with. First you need to call a saved object. This is done with the getLocal() function. getLocal is part of the SharedObject class and expects one parameter: the name of the object you want to call. If the object doesn't exist, it is created; now isn't that nifty. Anyway, the value that is returned by SharedObject.getLocal() is your cookie. It holds all the saved data and the functions you need to contol it. It's really easy to define variables in the sharedObject. All the data is held in the data object. So to define a variable all you have to do is define a variable in the data object. A little example:

myOjbect = SharedObject.getLocal("test"); //Get the 'test' SharedObject and save it in myObject myObject.data.myName = "Mark"; //Save the value "Mark" in the myName variable in the SharedObject

Now that the variables are created, there is one more thing you need to know. When you edit the object, the SharedObject isn't saved. If Flash would do that, it would be very inefficient, and would take up a lot of system resources. That's why Flash only saves the SharedObject when you tell it to. You can do that with the flush() function. When you call this function, all the values are saved:

myOjbect = SharedObject.getLocal("test"); //Get the 'test' SharedObject and save it in myObject myObject.data.myName = "Mark"; //Save the value "Mark" in the myName variable in the SharedObject myObject.flush(); //Save the values

Now all the values are saved. Calling works in exactly the same way.

First run
 
Second run

Last little tips

You've now basicly grasped sharedObject. All that remains are a few little leads. First is that you can check if you've allready defined a variable or not by comparing it to undefined:

if (myOjbect.data.myName == undefined) { //Variable doesn't exist so define it... myObject.data.myName = "Mark"; } else { //Do stuff with the existing variable... trace(myObject.data.myName); }

Or saving objects to the sharedObject...:

myObject.data.myArray = new Array(); myObject.data.myObject = new Object(); myObject.data.myObject.myFunction = function () { trace("function called!"); }

The possibilities are endless :)

Author: MicrOchip
Advertisements

Premium Partners

  Free Website Templates - Flash templates, Affordable Website Design, Website Templates, Website Redesign, Custom Website Design, Web Design Tutorials, Flash Tutorials, Promotion Tutorials - that is what we do. Metamorphosis Design Studio offers quality, free and low cost web site templates for your business and personal life, we also offer affordable web design and site re-design.
  Vertex Website Tempales - It saves tones of time and money to use pre-made web designs to build your web site. You need a web site but you don't want to pay thousands dollars to professional web design companies? Our web templates is just for you! They are designed to be easilly edited by your favorite html editor, like MS FrontPage
  Website Design Tutorials - Web site design is an area that simply takes experience to perfect. Get started with these tutorials covering everything from page layout to content tips. At Webdesigntutorials.net you will find all the Web-building tutorials you need, from basic HTML and XHTML to advanced Adobe Photoshop, Macromedia Flash MX and 3D Studio Max software.
Free website templates and paid web templates are great tools to make your websites look perfect! You will save time and money with our flash templates and free website templates Our visitors are satisfied with the quality of our free and paid website templates! Please visit our free website templates and paid website templates sections. We offer free web templates, free web layouts, free web page templates and other stuff for free download. All templates come with the html and external css file so you may easily edit HTML with your favorite HTML editor. Feel free to download our free web templates for your personal websites.

Terms of use depend upon the website template vendor.

Home  |  Submit Tutorial  |  Top Sites  |  Free Templates  |  Website templates  |  Privacy Policy  |  Contact Us

All Right Reserved by ProDesignHost.com