0

我正在尝试使用以下代码从 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'));
4

1 回答 1

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"));
于 2012-11-03T23:09:14.553 回答