Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public function loadStory(storyStub:StoryVO, recache:Boolean=false):StoryVO
{//Also bad
if (!storyStub.type)
populateEmptyStory(storyStub);
// Optionally force loading from disc and recaching
if (recache)
facade.removeProxy(storyStub.uid);
var cacheProxy:IProxy;
if (facade.hasProxy(storyStub.uid))
{
cacheProxy=facade.retrieveProxy(storyStub.uid);
}
else
{
var story:StoryVO=new StoryVO(readVO(storyStub));
cacheProxy=new Proxy(story.uid, story);
facade.registerProxy(cacheProxy);
}
return cacheProxy.getData() as StoryVO;
}
//Better, but not the best:
public function loadStory(storyStub:StoryVO, recache:Boolean=false):StoryVO
{
// Optionally force loading from disc and recaching
if (recache)
facade.removeProxy(storyStub.uid);
var cacheProxy:IProxy;
if (facade.hasProxy(storyStub.uid))
{
cacheProxy=facade.retrieveProxy(storyStub.uid);
}
else
{
var story:StoryVO=new StoryVO(readVO(storyStub));
if (storyStub.uid == story.uid)
{
cacheProxy=new Proxy(story.uid, story);
}
else
{
populateEmptyStory(storyStub);
cacheProxy=new Proxy(storyStub.uid, storyStub);
}
facade.registerProxy(cacheProxy);
}
return cacheProxy.getData() as StoryVO;
}
private function populateEmptyStory(story:StoryVO):void
{//simple story
story.cast=castProxy.createCast(story.name);
story.milieu=milieuProxy.createMilieu(story.name);
story.getNewScene();
writeVO(story);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.