package
{
	import flash.net.SharedObject;
	
	public class Data extends Object
	{
		
		public function Data()
		{
			super();
			this.scoreRecordList = new <Object>[
				{"name": "", "score": ""}, 
				{"name": "", "score": ""}, 
				{"name": "", "score": ""}, 
				{"name": "", "score": ""}, 
				{"name": "", "score": ""}
			];
			if (this.share.data.rank == null)
			{
				this.share.clear();
				this.share.setProperty("rank", this.scoreRecordList);
			}
			if (this.share.data.prevUserName == null)
			{
				this.share.setProperty("prevUserName", this.prevUserName);
			}
		}
		
		private const share:SharedObject = SharedObject.getLocal("panda");
		
		public function save():void
		{
			this.share.setProperty("s1", this.bamboo);
			this.share.setProperty("s2", this.bestScore);
			this.share.setProperty("s3", this.shoots);
			this.share.setProperty("s4", this.milk);
			this.share.setProperty("s5", this.amulet);
			this.share.setProperty("s6", this.consumption);
			this.share.setProperty("s7", this.achievement);
			this.share.setProperty("rank", this.scoreRecordList);
			this.share.setProperty("prevUserName", this.prevUserName);
		}
		
		public function load():void
		{
			this.bamboo = int(this.share.data.s1);
			this.bestScore = int(this.share.data.s2);
			this.shoots = int(this.share.data.s3);
			this.milk = int(this.share.data.s4);
			this.amulet = int(this.share.data.s5);
			this.consumption = int(this.share.data.s6);
			this.achievement = int(this.share.data.s7);
			this.scoreRecordList = (this.share.data.rank) ? this.share.data.rank : new Vector.<Object>;
			if (this.share.data.prevUserName != null)
			{
				this.prevUserName = this.share.data.prevUserName;
			}
		}
		
		public var bamboo:int;
		
		public var bestScore:int;
		
		public var scoreRecordList:Vector.<Object>;
		
		public var shoots:int;
		
		public var milk:int;
		
		public var amulet:int;
		
		public var consumption:int;
		
		public var prevUserName:String = "Player Name";
		
		public var achievement:int;
	}
}
