Fixing the Fanfou AIR Client "Acting Up" Issue
Ever since I added the minimize-to-tray feature last time, I’ve been hearing about one “freak-out” paranormal event after another — you type in your own username and password, and the login info th...
Ever since I added the minimize-to-tray feature last time, I’ve been hearing about one “freak-out” paranormal event after another — you type in your own username and password, and the login info th...
Fanfou 1.7 released, sharing part of the code for the newly added minimize-to-system-tray feature:
Reflection: I was too lazy — too lazy to check the official docs for how to minimize to the tray. As it turns out, AIR had this designed in all along. See the official AIR document DEV_GUIDE_FLASH, <Chapter 13: Taskbar icons>. Let me study it now, and put together a Chinese doc along the way to atone. Overview: About taskbar iconsMany operating systems provide a taskbar where applications can display a small icon representing themselves. ADOBE AIR exposes an interface for interacting with an application’s taskbar icon through the NativeApplication.nativeApplication.icon property. AIR creates the NativeApplication.nativeApplication.icon object automatically. The type of this object is either SystemTrayIcon or DockIcon, depending on the operating system.
Supports minimizing to the system tray: clicking the minimize button no longer takes up space in the taskbar — it minimizes to the system tray instead. Thanks for your support. Online install URL C...
Yesterday morning, AIR auto-updated and installed itself in Chinese~ At the time I had no idea AIR 1.1 was released that very day. So exciting. Adobe AIR lets you keep your favorite web apps with y...
Quick Start Examples:Example 1. Reading XML var testXML:XML; var file:File = File.documentsDirectory.resolvePath(“Mousebomb/test.xml”); var fileStream:FileStream = new FileStream(); fileStream.open(file, FileMode.READ); testXML = XML(fileStream.readUTFBytes(fileStream.bytesAvailable)); fileStream.close(); The example uses the readUTFBytes() method to read the content and convert it into an XML object.
What is a File object? A File object is a pointer to a file or directory in the file system. For security reasons, it’s only available in AIR. What can a File object do? Get specific directories, including the user directory, the user documents directory, the directory from which the application was launched, and the application directory Copy files and directories Move files and directories Delete files and directories (or move them to the trash) List the files and directories in a given directory Create temporary files and folders Create directories Read file information Get file system information
On May 17, I ran into a frustrating situation with the Fanfou AIR client: “after AIR opens an XML file, it caches it, so it can’t refresh in time.” As I’d imagined it, I just needed to click a button to refresh the network data, but the data was cached — AIR preferred the local data and wouldn’t update in time. Very annoying. In the end I had to resort to “unorthodox measures” — To deal with this kind of failure to refresh due to caching, there’s a trick: add a parameter to the requested URL. For example, if you’re requesting a.xml?user=b, then every time you need to refresh, change it to request a.xml?user=b&r=1. Increment the value of r by 1 each time, and with this little hack you can get the data to refresh. Today I poked around the official site and found that URLRequest in AIR apps has two properties that can handle this (finally, something that stands up for us common folk~). They are:
AIR lets us build applications that work with the file system. Using the classes provided by the Adobe® AIR™ file system API, you can access the host’s file system — reading, managing, creating, and deleting directories and files, writing data to files, and more. I’ve broken working with the file system down into three parts of AIR file operations: AIR file basics (below) Using the File object to work with files and directories Using the FileStream object to read and write files Language reference for the relevant classes flash.filesystem.File flash.filesystem.FileStream flash.filesystem.FileMode
Today a guy in the FLEX group brought up AIR cache clearing, so I went wandering through the official docs again, and while I was at it I came across AIR’s URL schemes. Two of them I’d never used: app: and app-storage:. Here are the details: The standard URL schemes below are supported in any security sandbox in AIR: http: and https: — these two are of course web URLs. file: — this one is of course a local file URL. The schemes below are used by content running in the application security sandbox: app: Use this to specify a path relative to the top level of the application installation directory (that is, the application source directory) — the directory that contains the application descriptor file. For example, the one below points to the resources subdirectory under the application’s top-level directory: app:/resources