I have an application that is loading an swf. I can use that swf several times until there is a new one on the server. Therefore, I want to save as a SharedObject the loader containing the swf. Next time I could use the loader from the SharedObject instead of having to load the swf again (since it was already loaded one time).
For that I do the following:
var sObject: SharedObject = SharedObject.getLocal('PrefsObj');//my SharedObject.
registerClassAlias( "remoteSharedObject.NxLoader", NxLoader );//I register every time my custom Loader class which just extends from Loader.
if(sObject && sObject.data && sObject.data.loader)//I check if the sharedObject is empty? If not I get the previously saved loader.
loader = sObject.data.loader as NxLoader;
else//if it's empty I create the loader and load the bytes
{
loader = new NxLoader();
loader.loadBytes(swfBA,context);
}
this.addChild(loader);//add the loader.
sObject.data.loader = loader;//save the loader on my sharedObject for next time.
sObject.flush();//done.
What am I doing wrong? The loader inside the SharedObject is not recognized and comes as an Object. When it reaches the addChild method - Boom! -> Main Thread (Suspended: TypeError: Error #2007: Parameter child must be non-null.)
Thanks