GithubHelp home page GithubHelp logo

longde123 / airfilesave Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chamberlainpi/airfilesave

1.0 2.0 0.0 376 KB

Ever wanted to dynamically write local files from a Flash game/app at runtime (without server-side scripts, or annoying File Dialog prompts)? This handy AIR app can serve as a 3rd-arm for your Flash projects that needs to dynamically update JSON, TXT, or even ByteArray files. Also useful for launching NativeProcess (batch, commands, etc.)

Batchfile 11.64% HTML 2.96% ActionScript 85.40%

airfilesave's Introduction

AIRFileSave

Latest Updates:

You can now Append data to a file (instead of having to remember the whole file each time). This becomes useful for writing continuous logs, especially automated projects.

See what else has changed: https://github.com/bigp/AIRFileSave#updates


Ever wanted to dynamically write local files from a Flash game/app at runtime (without server-side scripts)? This handy AIR app can serve as a 3rd-arm for your Flash projects that needs to dynamically update JSON, TXT, or even ByteArray files. Also useful for launching NativeProcess (batch, commands, etc.)


It's true, there already exists a way of saving files from a Flash app by prompting a FileReference dialog, letting the user pick a path / filename and saving the bytearray to the user's system.

But what if you're working on a personal project? What if you're adjusting certain values in an XML or JSON file to tweak your game's flow? What if you're calibrating the scroll speed of your UI menus? Are you going to constantly go back and forth between editing and compiling your project until you get it right?

A Different Approach

Since you probably know the path to the configuration/levels files of your game and/or app, why not integrate some kind of auto-save in your project?

The way this works - AIRFileSave is an AIR app that uses a LocalConnection approach to "listen" to the client (your game/app) to initiate any file writing / reading / directory-listing commands.

How it works

You ask: "If this is using LocalConnections, do I need to setup the client LocalConnection to communicate with the AIR app?" - No worries! You don't have to setup a bunch of cumbersome LocalConnection details yourself in your project! This is handled for you in the client SWC, which you can create from the AIR app directly:

How it works


Usage of Client SWC

//Instantiating a new Client automatically connects to the AIR app.
var theClient:AIRFileSaveClient = new AIRFileSaveClient();

//Save a plain text file:
theClient.saveText("myFileName.txt", "Hello World.");

//Save a byte-array file:
theClient.saveBytes("myDataFile.bin", theByteArray);

//List a Directory:
theClient.listDirectory("C:/Temp/", function( pFileNames:Array ):void {
    trace(pFileNames);
}

//Create / Remove:
theClient.createDirectory("theDirName", onDirCreated);
theClient.deleteDirectory("theDirName", onDirDeleted);
theClient.deleteFile("theFile.txt", onFileDeleted);

//Last but not least, here's a way to call a command (Batch) file: (not fully implemented yet)
theClient.startCommand( "theCommand.bat", ["Hello", "World"], onCommandCompleted);

Demo

You can find a pre-release *.EXE installer on this GitHub page: https://github.com/bigp/AIRFileSave/releases

Also, once you have the AIR app running, you can try this online demo to see if it writes a plain text file under: C:\temp.txt

Try it: http://pierrechamberlain.ca/others/airfilesaveclient/index.html

Updates

(2014-08-14)

  • Added "appendText()" and "appendBytes()" methods to the Client and Server.
  • Refactored so that appendText/appendBytes/saveText/saveBytes reuse the same core method but only differ in which FileMode (APPEND vs. WRITE) type they use.

airfilesave's People

Contributors

chamberlainpi avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.