How reading exif metadata from file - actionscript-3

I'm trying to implement the following Exif reading library with as3, but I can't load the browsed file.
In the library example they use loader.load(new URLRequest("http://www.example.com/sample.jpg")); for loading the image, the problem in my application is that the file is selected by a file-browser in a local computer.
I tried a fileReference.name but it doesn't work, the only way that I found to make my test, is putting a file in the same directory than the .swf like this :
loader.load(new URLRequest("IMG_001.JPG"));
Can you tell me what is the parameter that I can put in the URLRequest function to get the path of the selected file ?
Thank you

Related

Trying to load local json file with createjs

I'm trying to load animations from Adobe Animate and it works fine when loading from a web server. But when loading from a local folder, I get "Access denied". The offending line is
loader.loadFile({ src: "images/1170_atlas_.json", type: "spritesheet", id: "1170_atlas_" }, true);
I should be able to simply include the contents of the file in a variable on the page and load the data directly. But I'm having problems finding the createjs function I need to call to load the spritesheet.Any ideas on how to do this?
You can not load JSON locally without doing some things like forcing Chrome to allow file access.
You can also get around it using JSONP, which loads the content as JavaScript.
If you want to manually load the contents, and embed your JSON in your page, you just have to make a new SpriteSheet manually. The EaselJS SpriteSheet docs have examples of this.
Cheers.

AS3 URLLoader unable to find local file

Using AS3 Loader object's load(new URLRequest('file.swf'), and the file is in the same directory as the FLA file. Just read that flash looks for files based on the application directory, but even when using the absolute file path flash can't find it such as "C:\Users\acerbook\Desktop\swf2\file.swf".
i keep getting "Error #2044: Unhandled IOErrorEvent:." and "Error #2035: URL Not Found.", seemingly regardless
Edit: Tested with adobe's preloader files and it worked, so there must be some issue with my AS, will keep checking.
You did read wrong, files are loaded from the location of the generated swf file or the generated html file (if running inside a html), files are NEVER loaded according to the project directory location. If you have set your swf to be exported to a different folder then loading operations run from that location.
The absolute path you are using is not a valid url and so a URLRequest can't find it.

How to load a local directory in as3

I want to load a directory in actionscript. To do that I use the File class but sadly it doesn't work.
Here is what I did. First I created the directory in the applicationStorageDirectory using this code:
var root:File = File.applicationStorageDirectory.resolvePath(UIDUtil.createUID());
root.createDirectory();
After that I dispatch an event so that the application copies some files into that folder. To do that I use the method File.copyToAsync (that works, so this is not the problem). When all files are copied to that directory I try to load that directory using the File call again. The reason I want to do that is, that I need the content/data as a byte array. The data property of the File class is only set when the load method is called successfully before.
Since the directory is in the application storage directory (the url property of the file object has this content: app-storage:/FF011DBC-2E92-46A8-D5F8-29FE1DD8FA7A) I thought just calling the load method would work. I was wrong... Although the documentation of that method says I can just call that method when the application runs in AIR and the file to load is inside the application sandbox, I get the following error:
Error #2044: Unhandled IOErrorEvent:. text=Error #2038: File I/O Error.
at flash.filesystem::File/resolveComponents()
at flash.filesystem::File/resolvePath()
...
Do you have any ideas what could be wrong? Is it even possible to load a directory using the File class? Or does that error occur because the isDirectory flag is set to true in the file object?
kind regards
Markus
I believe a File, when pointing to a directory, does not contains the data of the files contained inside it. You would have to use File.getDirectoryListing() to loop over all files the folder, and append their bytes to the ZIP archive separately. Don't forget to check if you come across sub-directory...
You can check this link for an example of how to do this.

Load all images from internal application

I am trying to load all the .png files from an internal application folder into a list control and I am stuck on exactly how to do it. I have tried httpservice to get the folder and count how many images there are so I can loop through them but I just cant figure that out.
File structure
-src
-(default package)
-my application files
-icons
-all my .png files
httpService i tried:
<s:HTTPService id="loadAllImages" destination="/icons" result="gotImages(event)" fault="loadAllImagesFault(event)"/>
This always results in directory not found. Am I going about this completely wrong? Anyone have a suggestion?
You can't do this. To store an image within an Flash application (SWF or AIR), you must embed it either using #Embed('') in MXML or by using the [Class] method.
The only way to actually reveal a folder directory of an internal folder in an AIR app is by using File (which is an AIR only class).
var file:File = File.applicationDirectory;
file.browseForDirectory('icons'); ; //unsure if that will pull an internal folder or not, but you get the idea
If this is an external directory (doesn't sound like it is), I believe you would do it how you show in your question (although I have never needed to use this method, so I don't know if/how it works)

AS3 - AIR - From a swf path file to a ByteArray

I am coding an AIR application.
I've got directly a path of a swf file (because it was stored in a xml file).
Do yo know if it is possible to get the ByteArray from this file ?
I know that FileReference do that very well, but this class need a select event. But it isn't my case because I've allready got my path.
Thanks a lot for your answers !
In AIR, you can read/write files directly using flash.filesystem.File and flash.filesystem.FileStream.
See, for example, this article.
however you can load it with URLStream and get a ByteArray with URLStream.readBytes()