PDA

View Full Version : Local shared object - error


fluen
06-15-2010, 10:07 AM
Greetings to all,

I am trying to save text via local shared object. But I get the error 1009 cannot access a property or method of a null object reference.

There is a blue arrow pointing to the line where this code is located.
tA.text=sharedObj.data.tasks;

The weird thing is that the code works fine when i run it in an new mxml with out the rest of my code.

Thank you for your input.

//constructor
private function init():void {
so();

pimView = this;
dataModel = new DataManager();
control = new PIMController(dataModel, pimView);
appCon = new AppointmentController(dataModel, pimView);


}

public function so():void{
sharedObj = SharedObject.getLocal("tasks");
if (sharedObj.size > 0)
tA.text=sharedObj.data.tasks;

}


private function saveTasks():void {
sharedObj.data.tasks = tA.text;
sharedObj.flush();
}

fluen
06-18-2010, 07:32 PM
Hi all,
I solved the problem by writing this: creationPolicy="all" :D
Before I implemented the code, the component instantiation life cycle was trying to acces something that was not yet created.