Newest Articles

Flash Media Player
XML Driven Pie Chart
Base Defender
Hangman Game
8 Ball Pool

Popular Articles

Catapult Game
True Fullscreen Flash Mode
Mp3 Player with XML Playlist
Album Slide
Infinitely Zooming Image

Random Articles

Album Slide
Growing Tree using Recursion
Image Rotator with blur and fadeout
Flash Media Player
Picture Puzzle


Shapes the Game
Link to SwfSpot
Swf Spot

Contact me on Google+

rss feed

Storing Data Similar to Cookies

Storing Data Similar to Cookies
AddThis Social Bookmark Button
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:
  1. //Select the local shared object
  2. var so:SharedObject = SharedObject.getLocal("setbgcolor");
  3. //check if the bgcolor has been previously set
  4. if(!=undefined){
  5.   //if set, set the background color to that color
  6.   setcolor(;
  7. }
  8. //set the background color and save it.
  9. function setcolor(color){
  10.   var bgcolor = new Color(bg);
  11.   bgcolor.setRGB(color);
  13.   //force the file to be written
  14.   so.flush();
  15. }
Each button in the applet calls the following code in the on(press) function: setcolor(0x00FF00); 0x00FF00 is a hexadecimal number, and you can tell that because hexadecimal numbers begin with 0x in flash. To delete a set variable in this applet use either delete; or so.clear();

Download Source File
Comments Currently Disabled