我正在尝试使用以下代码保存并从adobe air应用程序获取数据。但它只是保持警报只是未定义。有人能找到错误吗?
function saveData(n, v){
var bytes = new air.ByteArray();
bytes.writeUTFBytes(v);
return air.EncryptedLocalStore.setItem(n, bytes);
}
function getData(n){
var storedValue = air.EncryptedLocalStore.getItem(n);
return air.trace(storedValue.readUTFBytes(storedValue.length));
}
saveData('item1', 'value1');
alert(getData('item1'));
答案 0 :(得分:2)
尝试删除air.trace
功能
function saveData(n:String, v:String):void
{
var bytes = new air.ByteArray();
bytes.writeUTFBytes(v);
air.EncryptedLocalStore.setItem(n, bytes);
}
function getData(n):String
{
var storedValue = air.EncryptedLocalStore.getItem(n);
return storedValue.readUTFBytes(storedValue.length);
}
saveData("item1", "value1");
alert(getData("item1"));