0

我正在创建一个使用 sharedobject 保存数据的游戏。我想让玩家可以选择将文件保存到哪里。有没有办法使用文件引用来完成这个?

下面是代码示例:

import flash.net.SharedObject;

var saveDataObject:SharedObject;
saveDataObject = SharedObject.getLocal("savedata");

var playerHealth:Number = 10;
var playerStamina:Number = 4;
var playerCash:Number = 4;

//Save Function
function saveData(e:MouseEvent):void{
    saveDataObject.data.savedPlayerHealth = playerHealth;
    saveDataObject.data.savedPlayerStamina = playerStamina;
    saveDataObject.data.savedPlayerCash = playerCash;
    saveDataObject.flush();
    }

//Load Function
function loadData(e:MouseEvent):void{
    playerHealth = saveDataObject.data.savedPlayerHealth;
    playerStamina = saveDataObject.data.savedPlayerStamina;
    playerCash = saveDataObject.data.savedPlayerCash;
    }
4

0 回答 0