Writing text to .txt files using actionscript - actionscript-3

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.

Related

Is ActionScript a more secure alternative to Flash Player?

With all the security issues with Flash lately I am looking at alternatives for if/when Flash is retired at my work. We use strictly IE 11 and IE11 seems to be very finicky about css3 animations. I see the new Flash has the ability to publish the file as embeddable actionscript files instead of a swf file. Is this a viable alternative to Flash or is this vulnerable to the same security issues Flash has? My assumption is the vulnerabilities exist in the Flash players but I want to be certain.
No. Apples and Oranges, really.
The Flash Player is a runtime environment of the Flash platform (AIR being another). It "plays" .swf files.
ActionScript is the scripting language that an apropriate compiler (mxmlc, for example) compiles into .swf files.
I see the new Flash has the ability to publish the file as embeddable ActionScript files instead of a swf file.
You can embed any file, but guess where you embed it into? Into the swf file.
Again, ActionScript is the programing/scripting language and an swf file is the compiled result.
Flash CC can also export to JavaScript/HTML/CSS. That means that instead of creating a .swf file, a bunch of JavaScript/HTML/CSS files are created.
As you can see in the link you provided, the feature sets are not equivalent.
Note: The 3D Rotation tool in the toolbar of the Flash Professional CC workspace is disabled when creating HTML5 Canvas documents because it is specific to SWF projects and not supported in the HTML5 specification (see Figure 3).
There's a whole bunch of other things not supported
Recommendation
If one comes to the conclusion that the Flash platform is not an appropriate publishing platform any more, why bother sticking to the Adobe Flash program?
It appears to be disadvantageous to cling to the program, just for the sake of keep on using it.
Why not use the CreateJS library on its own? Or any of the other dozens of great JS libraries? There's a lot to explore in the post-Flash era and it is very exiting. It's not a good idea to stay behind, still coding in dead languages, hoping that there's a translator to communicate with the Present. Try to order a pizza in Latin and you know what I mean.
If the goal is to target multiple different platforms, there are alternative tools to do this like defrac or Haxe that allow you to compile from one languages to many platforms.
The answer to the question if compiling ActionScript to JavaScript/HTML/CSS is a reasonable workflow for the future is no. It might be a good tool to port existing projects, but not to neglect the current developments in the JavaScript/HTML/CSS realm.
I seem to get almost weekly Java updates. All these technologies can have security issues, it's just that Adobe react quickly, and release a fix as soon as possible. That does come with a certain amount of publicity.
About using CreateJS on its own, you could do that, and come up with your own libraries to create hierarchy, synchronizing sound to visual events, asset management, etc. You could also do everything purely in code, if your imagination is good enough to do that. Or, you could just use Flash Pro, and get all of those things for free.

Create folder and directory in actionscript

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.

How to create a Flash Movieclip via a web interface?

Forgive me if this is not the correct place to ask such a question.
Basically, I am looking for a way to allow someone to easily (at least, easier then diving into Flash) create a basic Flash animation (movieclip) with some placed image assets and text, all via a web interface.
I was thinking along the lines of using jQuery to allow drag and drop assets, of which you'd "record" the co-ordinates and relay that to Flash somehow to create the SWF file.
Or would it be better to create a tool in Flash (surely making operations easier) and then have some kind of "save" button to render out the SWF?
I'm totally open to suggestions.
Thank you
If you really need to produce a stand-alone SWF file (and not just a config file for you own "player"), I would probably do it like this;
1) Create your editor in whatever system you feel like (flash, jquery etc).
2) Build a config file in the client. This is used, together with all the resources the user added, to play back the animation.
3) Upload said assets and config file to your web server.
4) Use the flex compiler (on the server) to produce the resulting SWF, combining your player with generated AS3 which embeds the uploaded resources as needed, to make it available to the player.
5) Give the user a download link for the newly generated SWF file.
I don't think there is any swf compiler available for Flash (actionescript). You may create a swf that allows users to create an animation, save it as a home-made vector format, and then replay it. But I don't believe you can create and independant swf file with only the created animation in it.
Just think about a player in Flash, and a format that the player will read (xml, json, name it...). You can either generate the input with jQuery or Flash, and then feed it into your player to display it. You will eventually need two files.
Apparently this library allows you to compile SWFs at runtime. I haven't used it myself (yet) and don't know how stable or flexible it is, but it appears to be what you're looking for. I'd recommend giving it a spin and seeing if it's sufficient.
I'm not exactly sure how it saves the file, so you might run into security problems since it's a web application. Hopefully it should be OK though.

Best way to make a downloadable version of a Flash game?

I already made a game with flash, and I want to provide an easy download for people that would rather play offline. Thing is, i use a folder whole structure to dynamically load content per level. Folder structure looks like this, not that it matters that much:
Game folder
animations
anim1.swf
anim2.swf
sounds
music1.mp3
soundeffect1.mp3
levels
level1.lev
level2.lev
myGame.swf
How should I go to distribute this? Should I just resort to make a zip file for the flash game and assume people know how to extract and open the swf? Is there any other way to port easily as an executable? Perhaps Adobe Air (not sure if this works though)?
Thanks, and please help!
Distributing a zip file is the only option if you really want that structure to prevail. Else,
Embed all the resources in the main (myGame) swf & distribute it.
Provide a html page for people who do not have standalone flash player installed.
Embedding as a single file allows the browser to cache the single swf & allow the player to keep playing offline until cache is cleared. So user might not even need an explicit download.
If you are using Flash Builder it is fairly straightforward to compile the application into a self-installing AIR executable (or DMG on a Mac). It is possible to include the AIR runtime which would avoid potential problems of the user not having the correct flash player for example.
An alternative to AIR would be to create a projector executable from inside the standalone Flash Player or from the Flash authoring environment.
Another option to using a zip file would be to use a free installer creator such as InnoSetup or Nullsoft on Windows, or Packager on Mac. Linux users are generally more tech savvy and so a tar would probably be well understood.
Adobe AIR works wonderfully! I use it for my own project, and your project should transition over to it with little to no modification (any issues should show up in the Compiler Errors and Output). The only downside is that, past AIR 2, there isn't any Linux support.
The other option is obviously to create a standalone .SWF projector inside a zip or installer, but in my opinion, that isn't the sleekest way to deploy for desktop. The advantage of AIR over this is that it gives you access to additional desktop functions that Flash Player doesn't.

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?