Login   Register  
Icontem

File: datatype_example.html

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Arturs Sosins  >  FCookie  >  datatype_example.html  >  Download  
File: datatype_example.html
Role: Example script
Content type: text/plain
Description: Example preserving data types
Class: FCookie
Store and retrieve values in Flash cookies
Author: By
Last change:
Date: 2011-04-30 05:06
Size: 1,881 bytes
 

Contents

Class file image Download
<!--
/*************************************************************
 * This script is developed by Arturs Sosins aka ar2rsawseen, http://webcodingeasy.com
 * Fee free to distribute and modify code, but keep reference to its creator
 *
 * This class can be used to manipulate SharedObjects (aka Flash cookies) 
 * using swf file provided in package with different domain and namespace sstings. 
 * This class can set values from javascript, get saved values from 
 * SharedObjects (preserving data types) and delete SharedObjects.
 *
 * For more information, examples and online documentation visit: 
 * http://webcodingeasy.com/JS-classes/Manage-SharedObjects-using-Javascript
**************************************************************/
-->
<html>
<head>
</head>
<body>
<p><input type='button' value='Set' onclick='try_set();'/></p>
<p><input type='button' value='Get' onclick='try_get();'/></p>
<p><input type='button' value='All' onclick='try_all();'/></p>
<script type="text/javascript" src="./fcookie.packed.js" ></script>
<script type="text/javascript">
var fc = new fcookie({onload: function(){alert("loaded");}});
//setter test
function try_set()
{
	fc.set("string", "somestring");
	fc.set("number", 11);
	fc.set("bool", true);
	fc.set("object", {"something": "nothing"});
	var obj = {"uno" : "one", "duo" : 2};
	//setting whole object
	fc.set(obj);
}

function try_get()
{
	//getter test
	var get = fc.get("string");
	alert(typeof(get) + " " + get);
	var get = fc.get("number");
	alert(typeof(get) + " " + get);
	var get = fc.get("bool");
	alert(typeof(get) + " " + get);
	var get = fc.get("object");
	alert(typeof(get) + " " + get["something"]);
}

function try_all()
{
	//get all
	var all = fc.get_all();
	for(var i in all)
	{
		alert(typeof(all[i]) + " " + i + " " + all[i]);
	}
}
</script>
</body>
</html>