我保存了一個位圖,我想在運行時加載它。加載保存的位圖
這裏是我的代碼:
var saveDataTxt:SharedObject = SharedObject.getLocal("File");
var textName:String; var textClass:Class;
textName = "Text0" + 1; textClass = getDefinitionByName(textName) as Class;
var tx:BitmapData = new textClass(); txtP[1] = new Bitmap(tx);saveDataTxt.data.txtArray[1] = txtP[1];
addChild(saveDataTxt.data.txtArray[n]);
,但它給我一個錯誤:
**TypeError: Error #1034: Type Coercion failed: cannot convert [email protected] to flash.display.DisplayObject.**
什麼解決辦法嗎?
它似乎像saveDataTxt.data.txtArray [n]不是一個displayobject,但只是一個常規的對象。什麼存儲在sharedobject中? – Marijn
我試圖在共享對象中保存位圖 –
您的問題可能是您需要在重新加載之前註冊該類。請參閱我對此問題的回答:http://stackoverflow.com/questions/15667848/as3-for -ios-how-to-serialize-an-array-and-then-save-it/15668079#:15668079 – BadFeelingAboutThis