Permalink
Browse files

Don't fail if db/fuschia doesn't exist

  • Loading branch information...
1 parent d1b35bb commit 892b6232d8eb98149ccc56b460612e35487492f1 @paulcarey committed Jan 12, 2009
Showing with 15 additions and 4 deletions.
  1. BIN bin/Fuschia.swf
  2. +15 −4 src/Fuschia.as
View
Binary file not shown.
View
@@ -18,6 +18,7 @@ package {
import flash.display.Sprite;
import flash.events.Event;
+ import flash.events.IOErrorEvent;
import flash.events.MouseEvent;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
@@ -34,7 +35,7 @@ package {
{
private var dbUri:String;
- private var metaData:Object;
+ private var metaData:Object = new Object();
private var nodeMap:Dictionary = new Dictionary();
private var edgeMap:Dictionary = new Dictionary();
@@ -171,7 +172,7 @@ package {
dbNameField.width = 100;
dbNameField.border = true;
dbNameField.defaultTextFormat = new TextFormat("Helvetica", 12);
- dbNameField.text = "db name";
+ dbNameField.text = "db uri";
return dbNameField;
}
@@ -217,9 +218,13 @@ package {
private function loadMetaData(docId:String):void
{
var metaDataUri:String = dbUri + "fuschia";
- loadData(metaDataUri, function (doc:Object):void {
+ loadData(metaDataUri,
+ function (doc:Object):void {
metaData = doc;
loadDataForDoc(docId);
+ },
+ function ():void {
+ loadDataForDoc(docId);
});
}
@@ -289,7 +294,7 @@ package {
loadData(toDocUri, displayInDocs);
}
- private function loadData(uri:String, func:Function):void
+ private function loadData(uri:String, func:Function, errorFunc:Function = null):void
{
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.BINARY;
@@ -301,6 +306,12 @@ package {
func(data);
}
);
+ loader.addEventListener(IOErrorEvent.IO_ERROR,
+ function(evt:Event):void {
+ evt.preventDefault();
+ errorFunc();
+ }
+ );
loader.load(new URLRequest(uri));
}

0 comments on commit 892b623

Please sign in to comment.