SharedObj
package
{
import flash.display.MovieClip;
import flash.display.Shader;
import flash.net.SharedObject;
import flash.events.MouseEvent;
public class SharedObj extends MovieClip
{
//创建一个共享对象
private var MySQL:SharedObject = SharedObject.getLocal("UserInfo");
public function SharedObj()
{
btn.addEventListener(MouseEvent.CLICK,upLoad);
clearBtn.addEventListener(MouseEvent.CLICK,onClearHandler);
}
private function upLoad(e:MouseEvent):void
{
if(MySQL.size == 0 || isNaN(MySQL.data.num))
{
MySQL.data.num = 1;
}
else
{
MySQL.data.num += 1;
}
MySQL.data["Count"+MySQL.data.num]=String(MySQL.data.num);
MySQL.data["username"+MySQL.data.num]=txt1.text;
MySQL.data["Account"+MySQL.data.num]=txt2.text;
MySQL.flush();
txt.text = String(MySQL.data.num);
}
private function onClearHandler(e:MouseEvent):void
{
MySQL.clear();
txt.text = "0";
}
}
}