Create new specified folder with AS3 and AIR - actionscript-3

I am relatively new to the AIR world and need some help (on Windows 7 operating system). I tried searching for help, but I am dumbfounded as what to do. My knowledge of ActionScript 3 is fundamental and I am completely new to working with Adobe AIR. I will keep this thread short and not go into great detail about the rest of my application.
Any help is appreciated, I am completely lost.
Steps:
The user runs my Adobe Air application.
(and it does open, just the buttons don't work yet)
User clicks the "Save As" button and is prompted with a window to choose the desired directory.
After they choose the directory the directory path is stored in a String variable.
Then the user clicks the "OK" button. This will grab the path directory variable and create a new folder. The folder will have the name from a variable string.

Here is a sample code for selecting a directory
protected function browseBtn_clickHandler(event:MouseEvent):void
{
var browseFile:File = FileUtils.documentsDirectory();
browseFile.addEventListener(Event.SELECT, fileSelected);
browseFile.browseForDirectory("Select Local Folder");
function fileSelected(e:Event):void {
browseFile.removeEventListener(Event.SELECT, fileSelected);
if(localDirPath.text != browseFile.nativePath){
localDirPath.text = browseFile.nativePath;
changed=true;
}
}
}
this is a sample, localDirPath is a TextInput where I display the selected path, changed is a flag, so you use the File class in AIR for Desktop.Check the documentation File Class Reference check the methods that contain "browse" like browseForOpen, browseForSave, createDirectory

Related

How can i back to the previous folder in a cloud app ? WP8

I'm doing a Cloud application. I have 2 VIews (RootView,FolderView)
I can navigate through multiple layers of folders (folder inside another folder).I used the same view to display the content of each folder.Only the properties of my element binded to the view are changing when the user click on a folder.
The problem I encountered is that im not able to back to the previous folder with the "back" button...Because the user doesn't navigate to a different view when he click on a folder...
When I click on the back button I come back to the root.(The rootView).
I tried to used the Navigate() function to reload the same view on the click on a folder but it seems that the OnNavigatedTo event is not called ...
What can I do to be able to back to the previous folder ?
I had to use this line of code to create a new instance of a view...Then I was able to navigate as I wanted with the back stack...
NavigationService.Navigate(new Uri(String.Format("/Views/BDocs/FolderView.xaml?id={0}", Guid.NewGuid().ToString()), UriKind.Relative));

AS3 flash.net.FileReferenceList.browse() accepts an array of FileFilter objects but seems Mac OS is using only the first element

I have a file upload component written in ActionScript 3. The component is using the FileReferenceList.browse() to let the user select the files to upload. This method accepts an array of FileFilter objects to narrow down the selectable file types.
Until this time I passed only one FileFilter element in the array - if I passed any. This worked well for years without any problem. But recently I ran into a situation when I thought I understand why this method takes an array of FileFilters. Probably I was wrong...
I have a service which designed (and used) to present visual material mainly (images), but it can deal with non-visual files too like .xls, .doc, .zip, etc. This means in practice that my admin will upload almost only images (99%) to this service BUT sometimes (s)he will upload 1-2 .xls, .doc or .zip, etc.
So from this point I didn't want to really block files outside the (image) filter. Just tried to "show" my admin user that the preferred files are images here, but at the end of the day (s)he must be able to upload any file type.
So, I did this:
var fileReferenceList : FileReferenceList = new FileReferenceList();
var imgFilefilter : FileFilter = new FileFilter("Images", "*.jpg;*.jpeg;*.gif;*.png");
var allFilesFilter : FileFilter = new FileFilter("All files", "*");
fileReferenceList.browse([imgFileFilter, allFilesFilter]);
This worked well - on Windows. When the file browser window comes up my user sees the image files only. But (s)he can switch to "all files" view and upload other files too.
But now it turned out my Mac users are screwed this way... The file browser window doesn't offer the possibility to switch to "All files" view, so they can not upload non-image files :-) arghhhh!
I'm wondering what could be the best solution for the problem I tried to describe above? A trivial solution could be that for Mac users I skip the FileFilter stuff entirely. But it is not the way I would prefer... OR did I missed something? Is it possible to somehow "convince" Mac file browser window to offer the possibility let my admin choose between the filters like Win file selector does?

Adobe Air Global Application Data

Does anyone know of a "Global" Application data for Adobe Air?
File.applicationStorageDirectory stores within the users area?
But we need the application to store information for the whole computer.
Something such as Windows: C:\ProgramData or AllUsers but there doesn't seem to be an official way to use these areas. (Trying to keep this as Standard as possible)
But there doesn't seem to be a File.allUsersApplicationStorage or File.globalApplicationData anything.
Now I know I could do something such as below for Windows Vista/7
var _path:String = File.applicationDirectory.nativePath;
// _np: C:\Program Files (x86)\ProgName\
_path = _path.substr(0, _np.indexOf(File.separator) + 1);
// _np: C:\
var _file = new File(_path).resolvePath("ProgramData/ProgName");
but I do not know what to do for WinXP, MacOS or Linux.
Any help would be welcome.
Couldn't you just use File.applicationDirectory? (Or rather, a subdirectory of it.) That would store your information in the application directory, and would be accessible from all users.
It might not be ideal, but it works.

Drawing on screen from a non-sprite object in Actionscript3

I'm trying to debug AS3 code on production. I have no access to trace(), can't write to disk or open a socket. What I want is to display something on screen.
With AS2 I could just access _root and create a text field with my trace data.
Any ideas how I can pull this off with AS3? My class extends Object, it is not a sprite and is never added to a parent display object.
Thanks! :)
Why can you not use trace?
You could download the Flex SDK ( http://opensource.adobe.com/wiki/display/flexsdk/Downloads ) and in the "bin/" folder is a program called "fdb" (Flex DeBugger) which is a command line tool for debugging .swfs.
Once downloaded, open up a terminal/cli, navigate to the "bin/" folder, and issue the command fdb http://example.com/index.html (./fdb http://example.com/index.html on a Mac) and the debugger will connect, assuming it's a debug .swf you've uploaded.
Fdb will also allow you insert break-points, watch/print/change variables etc. It's a very handy tool.

create a customised openFileDialog

i have an access program which i have been working on and i want to create a openFileDialog which will show specific folders and files. For e.g. when you click a button, instead of having the dialog showing all the folders and files, it will be given a parameter (folder name) and it will show only that folder. i am trying to achieve something similar to the windows search engine. the reason is that, my program has a folder which contains around 1000 sub folders which contain a documents. each subfolder has the same name as the document it contains. therefore, what i an trying to achieve is that from my Access Form, the user can click a button, and a dialog will pop up showing only the folder which contains the document the user is working on.
is this possible.
i would really appreciate your help thank you
Do you mean you want OpenFileDialog to start in a specific folder?
You can do it like this:
OpenFileDialog MyOpenFileDialog = new OpenFileDialog();
MyOpenFileDialog.InitialDirectory = "C:\Path\To\My\Selected\Subfolder" ;
MyOpenFileDialog.ShowDialog()
Access provides Application.FileDialog. If you want to use the ENUM for the dialog type, you'll have to add a reference to the Office Object library, but if you try to use the enum you'll get prompted and Access will add the reference for you. It's not much use, though, as it can otherwise be used quite easily with object variables instead of strongly-typed variables.
To learn how to use it, open the Immediate Window (Ctrl-G), type Application.FileDialog, and hit F1. That explains the basics.
For what it's worth, I was using Windows API code from the Access Developers Handbook before the Application.FileDialog was introduced (with A2002), so I continue to use that. I am pretty sure the functionality is identical, though Application.FileDialog probably has a spiffier interface (I don't know -- I don't use it!).