0
所以我試圖存儲和加載數據,但由於某些原因我得到錯誤代碼1046 - type was not found or was not a comile-time constant
和1120 - access of undefined property SharedObject
。與actionscript3中的sharedobject問題
我已經導入所需的正確的文件。
此代碼是在時間軸上的一個幀,一旦有人點擊該對應的代碼在頁面上應該運行。
代碼:
import flash.desktop.NativeApplication;
import flash.display.Sprite;
import flash.events.Event;
import flash.utils.setInterval;
// Listen for exiting event.
NativeApplication.nativeApplication.addEventListener(Event.EXITING, onExit);
// Also save every 30 seconds.
setInterval(save, 30*1000);
// Load data.
load();
function onExit(e:Event):void
{
save();
}
function save():void
{
// Get the shared object.
var so:SharedObject = SharedObject.getLocal("myApp");
// Update the age variable.
so.data['age'] = int(so.data['age']) + 1;
// And flush our changes.
so.flush();
// Also, indicate the value for debugging.
trace("Saved generation " + so.data['age']);
}
function load():void
{
// Get the shared object.
var so:SharedObject = SharedObject.getLocal("myApp");
// And indicate the value for debugging.
trace("Loaded generation " + so.data['age']);
}