Flex standalone application with no database
I am trying to develo开发者_JS百科p an application which can be used locally by my team mates. its a sort of issue tracking application with report generation. am planning to do it on flex. in my company environment, i do have a lots of restrictions like, can't install AIR, no database, etc.
so am planning to develop on flex app, and put it in a shared drive. now the main problem is how can i store data. i have an idea like using excel files as database. I want opinion about this option, as well as, if anyone has tried reading and writing excel files from Flex application I want the suggestions also.
Thanks, Anoop
Flex provides the RemoteObject, WebService, and HTTPService tags for accessing remote data and services. AIR Expands that a bit with some APIs for local file access (File) and SQL Lite database.
Without AIR APIs you won't be able to write local files; and I doubt you can write them. You could try to use HTTPService with a "file://" URL. I would expect cross domain issues.
Can you set up the Flex app to access a remote server? If so, you can have the server deal with creating and editing the excel files. but, if you could do that why not use a real database?
You can look at other tools to create desktop applications from Flex. I believe Janus is one option ( http://www.janus-flash.com/ ). You could also use Flash Pro and publish to an executable; but it would be difficult, but possible, to make that support Flex code. Zinc is another option ( http://www.multidmedia.com/ ).
If AIR isn't allowed, I'm not sure why these other options would be, though. I can't help but wonder if you're better off exploring an MS Access solution instead of trying to turn client/server technologies into desktop technologies.
You can read/write to local files using the FileReference class. I've used the FileReference class for opening and saving images without using serverside code.
Here is an example:
package
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.FileFilter;
import flash.net.FileReference;
import flash.net.FileReferenceList;
public class Main extends Sprite
{
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
//load a file when the application starts
var fileRef:FileReference = new FileReference();
var fileRefList:FileReferenceList;
fileRefList = new FileReferenceList();
fileRef.addEventListener(Event.SELECT, function(evt:Event):void {
fileRef.load();
});
fileRef.addEventListener(Event.COMPLETE, function(evt:Event):void
{
//do something with the loaded data here
trace(fileRef.data);
onSave();
});
var arr:Array = [];
arr.push(new FileFilter("Data file", "*.dat"));
//prompt the user for the file to load
fileRef.browse(arr);
}
private function onSave():void
{
var fileRef:FileReference = new FileReference();
fileRef.save("this is my data to save");
}
}
}
精彩评论