Storing Data Similar to Cookies
Description: Store data with flash so that data remains after closing an applet.
Author: John Bezanis
Added: March 29th 2007
Version: Flash 8
Flash uses Shared Objects to allow data to be stored even after a user closes a flash applet. This is very similar to a browser's use of cookies. Main code in the applet:
- //Select the local shared object
- var so:SharedObject = SharedObject.getLocal("setbgcolor");
-
//check if the bgcolor has been previously set
- if(so.data.bgcolor!=undefined){
- //if set, set the background color to that color
- setcolor(so.data.bgcolor);
- }
- //set the background color and save it.
- function setcolor(color){
- var bgcolor = new Color(bg);
- bgcolor.setRGB(color);
- so.data.bgcolor=color;
- //force the file to be written
- so.flush();
- }
Download Source File
Comments
April 18th 2007 05:04AM - Stefan
Hey Stefan,
You could use an if statement to see if the music has been set to on or off, or if it is not set.
You could use an if statement to see if the music has been set to on or off, or if it is not set.
April 19th 2007 01:04AM - John
Hello,How can I store data in flash
September 6th 2007 02:09PM - jp
hi, ay i want to make it so when the player gets up to a certain question in mi quiz, when they close it then re open it, its exactly where they left it, any suggestions on the code to do that??
January 21st 2008 03:01AM - pioallergenic
Hi,
Can u tell me how to change shared object pathe from "C:\Documents and Settings\Harish\Application Data\Macromedia\Flash Player\#SharedObjects\D8F43EBD\localhost\Sample\Sample.swf" to My "D:\Sample" folder. u can send solution to harish_neermarga@rediffmail.com
Plse help..
Thank you
Can u tell me how to change shared object pathe from "C:\Documents and Settings\Harish\Application Data\Macromedia\Flash Player\#SharedObjects\D8F43EBD\localhost\Sample\Sample.swf" to My "D:\Sample" folder. u can send solution to harish_neermarga@rediffmail.com
Plse help..
Thank you
June 13th 2008 01:06AM - Harish
How do you make a object create from another object, and make a enemy that disappears after hit by another object?
June 14th 2008 12:06PM - Dragonblue80
hello how to store the data obtained through the flash .....
as in the case of a data obtained through a questionnaire?
please send to drthomassebastian@rediffmail.com
as in the case of a data obtained through a questionnaire?
please send to drthomassebastian@rediffmail.com
December 8th 2008 08:12PM - thomas
Add a Comment






I have turn on/off music button on my web site. How can I store data if music is on or off. Thank u in advance.