I have a custom file type that I'm reading from and writing to within an AIR application. The file type is XML based but contains encoded data for an image. I've already defined the file type in my application manifest file using the tag which assigns a custom icon to the file.
开发者_开发问答What I'm trying to figure out is whether it's possible to set the icon for each individual file to be a preview of the image contained within.
there is nothing in the AIR sdk that will do this. it's up the operating system of your file to handle the file icons. i mean, you might be able to assign dynamically generated icons to that file, but you would have to create the icon, write it to your applicationStorageDirectory (ideally) and let your app assign the icon from there, assuming you could find a good way to dynamically change your app.xml file to point to your new icon file, which i don't believe is possible.
however, if your operating system can change your file icon, you can call native process on the file to handle the change this way.
for example, under Mac OS X, you can both automatically create and assign a new icon for an image file of the image contained in the file by writing the following command in Terminal:
$ sips -i FILE_NAME
therefore, if you deploy and AIR application for Mac OS X with a native installer, you can call that command on an image file using a Native Process.
精彩评论