samedi 11 juin 2016

Action Script 3 , SharedObject , Save Loader Data

I have a question where is my mistake and how can I improve it? the main thing is Image data have saved but I can't load it again

my data is an image

I get this error every time I have tried to load the loader

TypeError: Error #1034: Type Coercion failed: cannot convert Object@2802e5c9 to flash.display.Loader. at LoadAndSaveImage_fla::MainTimeline/LOADING_IMAGE()

var loader:Loader = new Loader();
var MY_DATA:SharedObject = SharedObject.getLocal("Kianoosh");

BROWSE.addEventListener(MouseEvent.CLICK, BROWSE_CLICKED);
SAVE.addEventListener(MouseEvent.CLICK, SAVE_CLICKED);
FR.addEventListener(Event.SELECT, SELECTED);
FR.addEventListener(Event.COMPLETE, COMPLETED);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, LOAD_COMPLETE);
LOADING_BTN.addEventListener(MouseEvent.CLICK, LOADING_IMAGE);

function BROWSE_CLICKED(evt:MouseEvent){
FR.browse();
}
function SELECTED(Event){
FR.load();
}
function COMPLETED(evt:Event){
loader.loadBytes(evt.currentTarget.data);
}
function SAVE_CLICKED(MouseEvent){
MY_DATA.data.MY_IMAGE = loader;
MY_DATA.flush();
}
function LOADING_IMAGE(MouseEvent){
loader = MY_DATA.data.MY_IMAGE;
} 

UIL.addChild(loader);

function LOAD_COMPLETE(Event){
loader.width = UIL.width;
loader.height = UIL.height;
}

Aucun commentaire:

Enregistrer un commentaire