Skip to content

Instantly share code, notes, and snippets.

@Ondina
Created December 29, 2011 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ondina/1534767 to your computer and use it in GitHub Desktop.
Save Ondina/1534767 to your computer and use it in GitHub Desktop.
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