Create folder and directory in actionscript - actionscript-3

As a part of flash application, I'm trying to store recorded files automatically to a specific path on users computer hard disk without they be aware.
Is there a way to create directory in actionscript?

If you are using Flash in a web browser, for security reasons there is not. the only option to store something locally within a web browser is to use shared objects (kind of like cookies), but this is likely not what you want.
If you are not in a web browser you can use either AIR or a third party wrapper such as Multidmedia Zinc (for an additional cost).
File options for AIR can be found here:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html
File options for Zinc can be found here:
http://www.multidmedia.com/support/livedocs/zinc/4.0/
EDIT
Since in your comment it sounds like your running in a web browser, you should leave it at simply streaming it to your server. If they have no internet connection there is no other good option other than live streaming using URLRequest, that is, if you are within a web browser.
Here is some additional reading on this subject:
Can Flash action script read and write local file system?

There's a tutorial at http://hub.tutsplus.com/tutorials/create-a-useful-audio-recorder-app-in-actionscript-3--active-5836?request_uri=%2Ftutorials%2Factionscript%2Fcreate-a-useful-audio-recorder-app-in-actionscript-3 which does exactly what you want. Ignore the timeline-driven approach if you wish.
It uses the micrecorder library from https://code.google.com/p/micrecorder/ which records the audio and offers a file for the user to download at the end.

Related

Possible to include mxmlc flex compiler inside an AIR app?

Im currently developing an swf 3D Player for the web with Flex SDK. My goal is to create an air application that lets the user load models and export them to .swf 3D player to make those 3d models viewable over the web. Im using FlashDevelop.
My original goal was to include the mxmlc compiler and the whole flex sdk inside my air apps bin directory and run those with airs native extensions with arguments(command line). The problem is that flex sdk is about 800Mb size and again required JRE to run mxmlc.
Is there a way to include a minimalistic compiler inside my air application which doesn't require 800mb+ ? I know I just could output a general swf that first loads a config file with paths to the model and textures and then loads those, but I want the models and textures to be included inside the swf to make those safe from being easily downloaded. Any suggestions?
This doesn't answer the specific question asked, but it's too long for a comment.
Your problem is not how to include the flex compiler with AIR, it's how to stop the models and textures in the SWF from being downloaded easily.
First of all, there's no 100% secure answer; the SWF format is easily decompiled (so embedding 1 file per SWF is out), and if determined enough, someone can look at the memory of your application to find what they need; this is all about stopping the easy copy.
Off the top of my head, these are some of the ways you can do it, assuming that your end goal is an online 3D model viewer:
1) Have your own format
While technically not impossible, it is pretty awkward; basically you write your own format for storing and displaying models (essentially what most 3D modelling software does). This means that if someone gets hold of a model file, it's useless to them unless they write a parser (naturally, you'll need to protect your display SWF). If the purpose of your viewer is for other users to buy the model, then they'll need it in a format that they can use, so your workflow goes something like this:
Create model in common format -> convert to custom format for display in your player -> user browses and hits "buy" -> they download the common format file
2) Load the 3D model from your site
The simplest option; just load the model directly from your server, similar to how you'd load an image. To stop people from downloading the file directly, store them above the htdocs folder, and access them through a local URI in flash. So your server file system looks something like this:
models
Model1
Model2
...
htdocs
index.html
3DPlayer.swf // loads models using a "../models/Model1" path
Thus only your SWF can access the models (though technically, as it's a file download, it might be in the browser cache - you should test it). To actually put the models into the models directory, you'll either need FTP access to the server, or need to create a simple script (using PHP or the like) to upload them.
3) Stream the assets to your SWF
As already mentioned, you can use something like ColdFusion to stream the assets directly to your SWF on demand. I've no experience in ColdFusion though, so I can't really say how this would work, but it shouldn't be too hard
4) DB connection
Assuming your models are stored as text blobs in a DB (e.g. MySQL or MongoDB), you can either connect directly with the SWF or use PHP and AMFPHP to connect to the db and stream the model that way.
You'll need to implement some security to make sure that people can't spoof your server calls, but the actual code to connect and return the value isn't too hard. As an added bonus, you're not tied to the SWF format, and can implement JS displayers etc if needed.

AIR iOS and Android login

I am building an app in AIR/AS3 for iOS and Android which requires user information to be submitted and stored in a remote DB. I guess I will need to build a register/sign in screen but just wondering what the best method to store the session information in the app.
I would like it that if the user closes the app the session remains when they start it again. I currently have suspend on exit in the app.xml file. Should I just remove this?
Cheers
Probably worth giving a flip through of this for some high level ideas (without the seminar it's difficult to get details out of this)
http://www.slideshare.net/marcocasario/local-persistent-data-with-actionscript-3-and-air
If you're using Flex I'd suggest starting here:
http://help.adobe.com/en_US/flex/mobileapps/WSb0a29bf92525419c-54dd253312afbec3ecb-8000.html
Otherwise either using the File/FileStream classes and an XML file or the SQLite options are both good as well depending on what you need to save/restore and how you'll be working with the data.
Learn about sqllite, xml files, and php files. Make the flash file call a xml file that talks to a php file that talks to the mysql server.
Otherwise look here: http://active.tutsplus.com/tutorials/actionscript/create-a-flash-login-system-using-php-and-mysql-part-1/

Writing text to .txt files using actionscript

Writing text to .txt files using actionscript. how? i couldn't find anything about that in the internet. is that possible? for flash player.
The flash player (the one in browsers) is run through a sandbox which prevents it from accessing or creating files on the users computer (imagine the chaos if it wasn't!), among other things.
You can store persistent data using SharedObject (but this is not readily visible to the user, only useful for storing settings etc).
The other options is to send the data to a web service which in turn would allow the user to download it. Those are your only options really.
Adobe Air is a different runtime, designed to be used for desktop applications. Eg like any program on your computer. It can do a lot more, but has to be downloaded and possibly installed before you can run it (it will not run from within a HTML page).
Check out Adobe AIR: http://www.adobe.com/devnet/air/flash/quickstart/articles/building_text_editor.html
That's impossible from flash player, only from air.

HTML File Upload - Practical Limit?

We are designing an internal web application to which we would like to upload a very large file (100mb). Is an HTML file upload even an option here?
If it is not, what other tools (Java applet, Silverlight, Flash) could we use to perform a file upload this large? Is uploading a file this large practical at all?
Edit: You can assume that there will be appropriate server side code accepting the file upload and handling the data. This question is specifically about the client side interface and the HTML file upload interface.
I'm no expert on file uploading, but my understanding is it's either impossible or very difficult to upload a file with HTML alone. You will probably need some server-side scripting like PHP, JSP, ASP.NET or something to process the upload and persist the file on your web server/database. Any well-designed implementation should allow for a size limit to be set and enforced, but with larger files it would be a good idea to include a progress indicator like a percentage and/or progress bar so the user knows the upload is still working and isn't hanging on slow connections.
I just downloaded this UploadBean component and deployed the WAR under the downloads section on an apache tomcat instance and the SimpleUpload.jsp example worked really well right out of the box. If you're using Java I'd highly recommend this approach.
http://www.javazoom.net/jzservlets/uploadbean/uploadbean.html
with javascript/jQuery/Mootools/Flash there are plugins that allows you to check file size before upload, and basically has server side script as fallback validation as well. Take a look at jQuery Uploadify or Mootools powered fancy upload they use flash and javascript with server side script in the backend. These two plugins use flash + JavaScript on client side
Being that it will be for an internal web application I am assuming you don't have any server-side imposed limits on the server that will be running this. If not then you should be able to upload large files.
See http://www.uploadify.com/ - nice and easy to implement
See http://encodable.com/filechucker/ - good if you are looking for more advanced management for your uploaded files.

Browser application & local file system access

I want to enhance my browser-based web application with functionality that enables management of local files and folders. E.g. folder tree structures should be synchronized between local workstation and server via HTTP(S).
I am aware of security-related limitations in browser-based applications. However, there are some techniques that "work around" these issues:
Signed Java applets (full trust)
.NET Windows Forms browser controls (no joke, that works. Just the configuration is horrible)
ActiveX
My question is: What do you use/suggest, both technology and implementation practice? Key requirement is that the installation process is as simple as possible.
Thanks for your opinions!
Google Gears.
it lets you write Javascript applications with a much bigger platform support than the usual browser, and go 'unconnected' with local file access, cache and DB. and if/when connected it syncs to the central server.
available for several browsers on all platforms; but still under heavy evolution.
Both Gears and Adobe Air require the user to manually select a local file before you get any programmatic access. Very limited because of security considerations when it comes to local filesystem access, so no chance for any web based file sync type functionality there as far as I can see. Maybe I'm wrong about Adobe Air but this is definitely the case with gears. But If I'm wrong let me know!
Silverlight 4 (still in beta) allows file system access:
"Read and write files to the user’s MyDocuments, MyMusic, MyPictures and MyVideos folder (or equivalent for non-windows platforms) for example storage of media files and taking local copies of reports"
http://www.silverlight.net/getstarted/silverlight-4/
Definitely not ActiveX. No sense spending time on something that out-of-date.
Adobe AIR (essentially, Flash for the Desktop), is something that we considered in my last contract, as opposed to Java applets. Last I checked, though it's been several months, the installation of the AIR runtime environment was fast and easy
Your best bet might be to write a custom application that interacts with your web application. For example, Dropbox lets you synchronize files across computers by use of a background application that watches a Dropbox-enabled folder. It also lets you view your Dropbox files online through a web browser. The Dropbox web application then allows you to delete/move/copy files which is echoed in your local filesystem.
In the demo of Google Wave...
http://www.youtube.com/watch?v=v_UyVmITiYQ&fmt=18
...at 15:30 in, a group of img files are drag-and-dropped from the file system to the browser. The functionality is attributed to Google Gears. This seems a bit different from what Daniel OCallaghan and the official documentation suggest is possible.
Anybody know what's actually possible w/ Google Gear and the local file system?