Skip to content

Instantly share code, notes, and snippets.

@jquave
Created October 15, 2012 22:02
Show Gist options
  • Save jquave/3895859 to your computer and use it in GitHub Desktop.
Save jquave/3895859 to your computer and use it in GitHub Desktop.
package {
import flash.net.*;
import flash.events.*;
// import flash.filesystem.*;
public class ImageArtifact implements IArtifact {
public var _date:Date;
public var _title:String;
public var imageClass:Class;
public var descriptionText:String;
public function get date():Date{
return _date;
}
public function get title():String{
return _title.concat();
}
public function get galleryImage():Class{
return imageClass;
}
public function get description():String{ return descriptionText; }
public function ImageArtifact(date:Date,title:String,imageClass:Class,descriptionTextFilename:String=null) {
this._date=date;
this._title = title;
this.imageClass = imageClass;
var myTextLoader:URLLoader = new URLLoader();
myTextLoader.addEventListener(IOErrorEvent.IO_ERROR, onError);
myTextLoader.addEventListener(Event.COMPLETE, onLoaded);
function onLoaded(e:Event):void {
var resultingString:String = e.target.data;
// var myArrayOfLines:Array = e.target.data.split(/\n/);
// trace(myArrayOfLines);
trace(resultingString);
this.descriptionText = resultingString;
}
function onError(event:IOErrorEvent)
{
// … a slack bastard
// TODO: get motivation to fix this
}
myTextLoader.load(new URLRequest("text/"+descriptionTextFilename));
try
{
myTextLoader.load(new URLRequest("text/"+descriptionTextFilename));//loader.load(new URLRequest("some url"));
}
catch(err:Error)
{
trace("Bad");
}
/*
// Pull description text out of file in to descriptionText variable
var file = File.applicationDirectory.resolvePath("text/"+descriptionTextFilename);
trace("file attempt at " + file.nativePath);
if(file.exists) {
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.READ);
var str:String = fileStream.readUTFBytes(file.size);
fileStream.close();
this.descriptionText = str;
}
else {
trace(descriptionTextFilename + " could not be found.");
this.descriptionText = descriptionTextFilename + " could not be found.";
}*/
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment