flex SharedObject应用
SharedObject功能强大,可以保存本地永久数据,存储和共享数据,实时共享数据,下面是一个保存本地数据的例子:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function save():void {
// 创建一个本地保存数据的对象s
var test:SharedObject = SharedObject.getLocal("testcookie");
test.data.user = user.text;
test.data.psw = age.text;
test.flush(); //提交保存
}
private function show():void{
var test2: SharedObject = SharedObject.getLocal("testcookie");
Alert.show(test2.data.user);
Alert.show(test2.data.psw);
}
]]>
</mx:Script>
<mx:VBox verticalAlign="middle" horizontalAlign="center">
<mx:TextInput id="user"/>
<mx:TextInput id="age"/>
<mx:Button label="提交" click="save()"/>
<mx:Button label="显示" click="show()"/>
</mx:VBox>
</mx:Application>